Mercurial > dwindows
annotate android/DWindows.kt @ 2841:3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
This allows us to replicate the iOS look that I implemented last week.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Fri, 16 Sep 2022 01:40:19 +0000 |
parents | 1f0017a07771 |
children | 22dd09e90112 |
rev | line source |
---|---|
2751
ee1cfa7d645e
Update copyright dates for the new year 2022.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2736
diff
changeset
|
1 // (C) 2021-2022 Brian Smith <brian@dbsoft.org> |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
2 // (C) 2019 Anton Popov (Color Picker) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
3 // (C) 2022 Amr Hesham (Tree View) |
2484
cb5b67154399
Android: The DWindows class should be org.dbsoft.dwindows, remove dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2483
diff
changeset
|
4 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
|
5 |
2788
8a4f162810c2
Android: During dw_file_browse() request read/write access to external
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2785
diff
changeset
|
6 import android.Manifest |
2526
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
7 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
|
8 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
|
9 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
|
10 import android.app.Dialog |
2522
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
11 import android.app.NotificationChannel |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
12 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
|
13 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
|
14 import android.content.pm.ActivityInfo |
2496
3bf2f08fdc45
Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2495
diff
changeset
|
15 import android.content.res.Configuration |
2643
28ca1e59e76f
Android: Catch NotFoundException when loading resource...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2642
diff
changeset
|
16 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
|
17 import android.database.Cursor |
2531
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
18 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
|
19 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
|
20 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
|
21 import android.graphics.drawable.GradientDrawable |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
22 import android.graphics.pdf.PdfDocument |
2490
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
23 import android.media.AudioManager |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
24 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
|
25 import android.net.Uri |
2522
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
26 import android.os.* |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
27 import android.print.* |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
28 import android.print.pdf.PrintedPdfDocument |
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
|
29 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
|
30 import android.provider.MediaStore |
2790
20d39af27aa4
Android: Add a new function for Android dw_file_open() which will open the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2789
diff
changeset
|
31 import android.system.OsConstants |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
32 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
|
33 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
|
34 import android.text.InputType |
2833
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
35 import android.text.format.DateFormat |
2476
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
36 import android.text.method.PasswordTransformationMethod |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
37 import android.util.* |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
38 import android.util.Base64 |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
39 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
|
40 import android.view.View.OnTouchListener |
2510
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
41 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
|
42 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
|
43 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
|
44 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
|
45 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
|
46 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
|
47 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
|
48 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
|
49 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
|
50 import androidx.collection.SimpleArrayMap |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
51 import androidx.constraintlayout.widget.ConstraintLayout |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
52 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
|
53 import androidx.constraintlayout.widget.Placeholder |
2522
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
54 import androidx.core.app.NotificationCompat |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
55 import androidx.core.app.NotificationManagerCompat |
2788
8a4f162810c2
Android: During dw_file_browse() request read/write access to external
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2785
diff
changeset
|
56 import androidx.core.content.ContextCompat |
2530
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
57 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
|
58 import androidx.core.view.MenuCompat |
2782
dff8fb5ddadd
Android: Added layout manager and code to trigger data change updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2781
diff
changeset
|
59 import androidx.recyclerview.widget.LinearLayoutManager |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
60 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
|
61 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
|
62 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
|
63 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
|
64 import com.google.android.material.tabs.TabLayoutMediator |
2790
20d39af27aa4
Android: Add a new function for Android dw_file_open() which will open the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2789
diff
changeset
|
65 import java.io.* |
2833
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
66 import java.text.ParseException |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
67 import java.text.SimpleDateFormat |
2490
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
68 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
|
69 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
|
70 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
|
71 import java.util.zip.ZipFile |
2713
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
72 import kotlin.math.* |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
73 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
74 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
75 // Tree View section |
2777
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
76 class DWTreeItem(title: String, icon: Drawable?, data: Long, parent: DWTreeItem?) { |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
77 private var title: String |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
78 private var parent: DWTreeItem? |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
79 private val children: LinkedList<DWTreeItem> |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
80 private var level: Int |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
81 private var isExpanded: Boolean |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
82 private var isSelected: Boolean |
2777
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
83 private var data: Long = 0 |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
84 private var icon: Drawable? = null |
2776
858155527b05
Android: Minor tree changes... mostly testing my system to push changes to GitHub.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2775
diff
changeset
|
85 |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
86 fun addChild(child: DWTreeItem) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
87 child.setParent(this) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
88 child.setLevel(level + 1) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
89 children.add(child) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
90 updateNodeChildrenDepth(child) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
91 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
92 |
2777
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
93 fun setTitle(title: String) { |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
94 this.title = title |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
95 } |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
96 |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
97 fun getTitle(): String { |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
98 return title |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
99 } |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
100 |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
101 fun setIcon(icon: Drawable?) { |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
102 this.icon = icon |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
103 } |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
104 |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
105 fun getIcon(): Drawable? { |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
106 return icon |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
107 } |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
108 |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
109 fun setData(data: Long) { |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
110 this.data = data |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
111 } |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
112 |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
113 fun getData(): Long { |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
114 return data |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
115 } |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
116 |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
117 fun getParent(): DWTreeItem? { |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
118 return parent |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
119 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
120 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
121 fun setParent(parent: DWTreeItem?) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
122 this.parent = parent |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
123 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
124 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
125 fun getChildren(): LinkedList<DWTreeItem> { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
126 return children |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
127 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
128 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
129 fun setLevel(level: Int) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
130 this.level = level |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
131 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
132 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
133 fun getLevel(): Int { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
134 return level |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
135 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
136 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
137 fun setExpanded(expanded: Boolean) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
138 isExpanded = expanded |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
139 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
140 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
141 fun isExpanded(): Boolean { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
142 return isExpanded |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
143 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
144 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
145 fun setSelected(selected: Boolean) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
146 isSelected = selected |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
147 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
148 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
149 fun isSelected(): Boolean { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
150 return isSelected |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
151 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
152 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
153 private fun updateNodeChildrenDepth(node: DWTreeItem) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
154 if (node.getChildren().isEmpty()) return |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
155 for (child in node.getChildren()) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
156 child.setLevel(node.getLevel() + 1) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
157 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
158 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
159 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
160 init { |
2777
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
161 this.title = title |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
162 this.icon = icon |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
163 this.data = data |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
164 this.parent = parent |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
165 children = LinkedList() |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
166 level = 0 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
167 isExpanded = false |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
168 isSelected = false |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
169 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
170 } |
2777
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
171 |
2785
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
172 class DWTreeItemView : LinearLayout, Checkable { |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
173 private var mChecked = false |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
174 private var colorSelection = Color.DKGRAY |
2781
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
175 var expandCollapseView: ImageView = ImageView(context) |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
176 var iconView: ImageView = ImageView(context) |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
177 var textView: TextView = TextView(context) |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
178 |
2785
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
179 fun updateBackground() { |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
180 if(mChecked) { |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
181 this.setBackgroundColor(colorSelection) |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
182 } else { |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
183 this.setBackgroundColor(Color.TRANSPARENT) |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
184 } |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
185 } |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
186 |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
187 override fun setChecked(b: Boolean) { |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
188 mChecked = b |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
189 updateBackground() |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
190 } |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
191 |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
192 override fun isChecked(): Boolean { |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
193 return mChecked |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
194 } |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
195 |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
196 override fun toggle() { |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
197 mChecked = !mChecked |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
198 updateBackground() |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
199 } |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
200 |
2781
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
201 fun setup(context: Context?) { |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
202 var params = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT) |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
203 this.orientation = LinearLayout.HORIZONTAL |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
204 params.gravity = Gravity.CENTER |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
205 expandCollapseView.layoutParams = params |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
206 expandCollapseView.id = View.generateViewId() |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
207 this.addView(expandCollapseView) |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
208 iconView.layoutParams = params |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
209 iconView.id = View.generateViewId() |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
210 this.addView(iconView) |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
211 params = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT) |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
212 params.gravity = Gravity.CENTER |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
213 textView.layoutParams = params |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
214 textView.id = View.generateViewId() |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
215 this.addView(textView) |
2785
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
216 colorSelection = context?.let { getPlatformSelectionColor(it) }!! |
2781
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
217 } |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
218 |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
219 constructor(context: Context?) : super(context) { |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
220 setup(context) |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
221 } |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
222 constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) { |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
223 setup(context) |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
224 } |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
225 constructor(context: Context?, attrs: AttributeSet?, defStyle: Int) : super(context, attrs, defStyle) { |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
226 setup(context) |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
227 } |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
228 } |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
229 |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
230 class DWTreeItemManager { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
231 // Collection to save the current tree nodes |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
232 private val rootsNodes: LinkedList<DWTreeItem> |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
233 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
234 // Get DWTreeItem from the current nodes by index |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
235 // @param index of node to get it |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
236 // @return DWTreeItem from by index from current tree nodes if exists |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
237 operator fun get(index: Int): DWTreeItem { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
238 return rootsNodes[index] |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
239 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
240 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
241 // Add new node to the current tree nodes |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
242 // @param node to add it to the current tree nodes |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
243 // @return true of this node is added |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
244 fun addItem(node: DWTreeItem): Boolean { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
245 return rootsNodes.add(node) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
246 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
247 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
248 // Clear the current nodes and insert new nodes |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
249 // @param newNodes to update the current nodes with them |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
250 fun updateItems(newNodes: List<DWTreeItem>?) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
251 rootsNodes.clear() |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
252 rootsNodes.addAll(newNodes!!) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
253 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
254 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
255 // Delete one node from the visible nodes |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
256 // @param node to delete it from the current nodes |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
257 // @return true of this node is deleted |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
258 fun removeItem(node: DWTreeItem): Boolean { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
259 return rootsNodes.remove(node) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
260 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
261 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
262 // Clear the current nodes |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
263 fun clearItems() { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
264 rootsNodes.clear() |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
265 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
266 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
267 // Get the current number of visible nodes |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
268 // @return the size of visible nodes |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
269 fun size(): Int { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
270 return rootsNodes.size |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
271 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
272 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
273 // Collapsing node and all of his children |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
274 // @param node The node to collapse it |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
275 // @return the index of this node if it exists in the list |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
276 fun collapseItem(node: DWTreeItem): Int { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
277 val position = rootsNodes.indexOf(node) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
278 if (position != -1 && node.isExpanded()) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
279 node.setExpanded(false) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
280 val deletedParents: LinkedList<DWTreeItem> = |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
281 LinkedList(node.getChildren()) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
282 rootsNodes.removeAll(node.getChildren()) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
283 for (i in position + 1 until rootsNodes.size) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
284 val iNode: DWTreeItem = rootsNodes[i] |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
285 if (deletedParents.contains(iNode.getParent())) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
286 deletedParents.add(iNode) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
287 deletedParents.addAll(iNode.getChildren()) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
288 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
289 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
290 rootsNodes.removeAll(deletedParents) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
291 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
292 return position |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
293 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
294 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
295 // Expanding node and all of his children |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
296 // @param node The node to expand it |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
297 // @return the index of this node if it exists in the list |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
298 fun expandItem(node: DWTreeItem): Int { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
299 val position = rootsNodes.indexOf(node) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
300 if (position != -1 && !node.isExpanded()) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
301 node.setExpanded(true) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
302 rootsNodes.addAll(position + 1, node.getChildren()) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
303 for (child in node.getChildren()) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
304 if (child.isExpanded()) updateExpandedItemChildren(child) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
305 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
306 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
307 return position |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
308 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
309 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
310 // Update the list for expanded node |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
311 // to expand any child of his children that is already expanded before |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
312 // @param node that just expanded now |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
313 private fun updateExpandedItemChildren(node: DWTreeItem) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
314 val position = rootsNodes.indexOf(node) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
315 if (position != -1 && node.isExpanded()) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
316 rootsNodes.addAll(position + 1, node.getChildren()) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
317 for (child in node.getChildren()) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
318 if (child.isExpanded()) updateExpandedItemChildren(child) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
319 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
320 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
321 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
322 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
323 // @param node The node to collapse the branch of it |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
324 // @return the index of this node if it exists in the list |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
325 fun collapseItemBranch(node: DWTreeItem): Int { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
326 val position = rootsNodes.indexOf(node) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
327 if (position != -1 && node.isExpanded()) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
328 node.setExpanded(false) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
329 for (child in node.getChildren()) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
330 if (!child.getChildren().isEmpty()) collapseItemBranch(child) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
331 rootsNodes.remove(child) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
332 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
333 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
334 return position |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
335 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
336 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
337 // Expanding node full branches |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
338 // @param node The node to expand the branch of it |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
339 // @return the index of this node if it exists in the list |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
340 fun expandItemBranch(node: DWTreeItem): Int { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
341 val position = rootsNodes.indexOf(node) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
342 if (position != -1 && !node.isExpanded()) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
343 node.setExpanded(true) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
344 var index = position + 1 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
345 for (child in node.getChildren()) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
346 val before: Int = rootsNodes.size |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
347 rootsNodes.add(index, child) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
348 expandItemBranch(child) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
349 val after: Int = rootsNodes.size |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
350 val diff = after - before |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
351 index += diff |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
352 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
353 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
354 return position |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
355 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
356 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
357 // Expanding one node branch to until specific level |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
358 // @param node to expand branch of it until level |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
359 // @param level to expand node branches to it |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
360 fun expandItemToLevel(node: DWTreeItem, level: Int) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
361 if (node.getLevel() <= level) expandItem(node) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
362 for (child in node.getChildren()) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
363 expandItemToLevel(child, level) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
364 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
365 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
366 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
367 //Expanding all tree nodes branches to until specific level |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
368 //@param level to expand all nodes branches to it |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
369 fun expandItemsAtLevel(level: Int) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
370 for (i in 0 until rootsNodes.size) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
371 val node: DWTreeItem = rootsNodes[i] |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
372 expandItemToLevel(node, level) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
373 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
374 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
375 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
376 // Collapsing all nodes in the tree with their children |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
377 fun collapseAll() { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
378 val treeItems: MutableList<DWTreeItem> = LinkedList() |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
379 for (i in 0 until rootsNodes.size) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
380 val root: DWTreeItem = rootsNodes[i] |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
381 if (root.getLevel() === 0) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
382 collapseItemBranch(root) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
383 treeItems.add(root) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
384 } else { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
385 root.setExpanded(false) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
386 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
387 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
388 updateItems(treeItems) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
389 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
390 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
391 // Expanding all nodes in the tree with their children |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
392 fun expandAll() { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
393 for (i in 0 until rootsNodes.size) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
394 val root: DWTreeItem = rootsNodes[i] |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
395 expandItemBranch(root) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
396 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
397 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
398 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
399 // Simple constructor |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
400 init { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
401 rootsNodes = LinkedList() |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
402 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
403 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
404 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
405 open class DWTreeViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
406 // Return the current DWTreeItem padding value |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
407 // @return The current padding value |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
408 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
409 // Modify the current node padding value |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
410 // @param padding the new padding value |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
411 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
412 // The default padding value for the DWTreeItem item |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
413 var nodePadding = 50 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
414 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
415 // Bind method that provide padding and bind DWTreeItem to the view list item |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
416 // @param node the current DWTreeItem |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
417 fun bindTreeItem(node: DWTreeItem) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
418 val padding: Int = node.getLevel() * nodePadding |
2781
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
419 val treeItemView = itemView as DWTreeItemView |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
420 |
2783
1b7c1b6ee760
Android: Fix tree basic functionality... need to add child branches,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2782
diff
changeset
|
421 treeItemView.setPadding( |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
422 padding, |
2783
1b7c1b6ee760
Android: Fix tree basic functionality... need to add child branches,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2782
diff
changeset
|
423 treeItemView.paddingTop, |
1b7c1b6ee760
Android: Fix tree basic functionality... need to add child branches,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2782
diff
changeset
|
424 treeItemView.paddingRight, |
1b7c1b6ee760
Android: Fix tree basic functionality... need to add child branches,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2782
diff
changeset
|
425 treeItemView.paddingBottom |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
426 ) |
2781
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
427 treeItemView.textView.text = node.getTitle() |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
428 treeItemView.iconView.setImageDrawable(node.getIcon()) |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
429 if(node.getChildren().size == 0) { |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
430 treeItemView.expandCollapseView.setImageDrawable(null) |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
431 } else { |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
432 if(node.isExpanded()) { |
2784
cccbb367bcd3
Android: Change the system resources used as expand/collapse for the tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2783
diff
changeset
|
433 treeItemView.expandCollapseView.setImageResource(R.drawable.ic_menu_more) |
2781
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
434 } else { |
2784
cccbb367bcd3
Android: Change the system resources used as expand/collapse for the tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2783
diff
changeset
|
435 treeItemView.expandCollapseView.setImageResource(R.drawable.ic_menu_add) |
2781
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
436 } |
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
437 } |
2798
a3d62de81ec0
Android: Changes to highlight the selected node of the tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2797
diff
changeset
|
438 treeItemView.isChecked = node.isSelected() |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
439 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
440 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
441 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
442 interface DWTreeViewHolderFactory { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
443 // Provide a TreeViewHolder class depend on the current view |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
444 // @param view The list item view |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
445 // @param layout The layout xml file id for current view |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
446 // @return A TreeViewHolder instance |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
447 fun getTreeViewHolder(view: View?, layout: Int): DWTreeViewHolder |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
448 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
449 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
450 class DWTreeCustomViewHolder(itemView: View) : DWTreeViewHolder(itemView) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
451 fun bindTreeNode(node: DWTreeItem) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
452 super.bindTreeItem(node) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
453 // Here you can bind your node and check if it selected or not |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
454 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
455 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
456 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
457 class DWTreeViewAdapter : RecyclerView.Adapter<DWTreeViewHolder> { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
458 // Manager class for TreeItems to easily apply operations on them |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
459 // and to make it easy for testing and extending |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
460 private val treeItemManager: DWTreeItemManager |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
461 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
462 // A ViewHolder Factory to get DWTreeViewHolder object that mapped with layout |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
463 private val treeViewHolderFactory: DWTreeViewHolderFactory |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
464 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
465 // The current selected Tree Item |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
466 private var currentSelectedItem: DWTreeItem? = null |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
467 |
2798
a3d62de81ec0
Android: Changes to highlight the selected node of the tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2797
diff
changeset
|
468 // The current selected Tree Item |
a3d62de81ec0
Android: Changes to highlight the selected node of the tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2797
diff
changeset
|
469 private var currentSelectedItemView: DWTreeItemView? = null |
a3d62de81ec0
Android: Changes to highlight the selected node of the tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2797
diff
changeset
|
470 |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
471 // Custom OnClickListener to be invoked when a DWTreeItem has been clicked. |
2785
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
472 private var treeItemClickListener: ((DWTreeItem?, View?) -> Boolean)? = null |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
473 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
474 // Custom OnLongClickListener to be invoked when a DWTreeItem has been clicked and hold. |
2785
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
475 private var treeItemLongClickListener: ((DWTreeItem?, View?) -> Boolean)? = null |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
476 |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
477 // Custom OnListener to be invoked when a DWTreeItem has been expanded. |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
478 private var treeItemExpandListener: ((DWTreeItem?, View?) -> Boolean)? = null |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
479 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
480 // Simple constructor |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
481 // @param factory a View Holder Factory mapped with layout id's |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
482 constructor(factory: DWTreeViewHolderFactory) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
483 treeViewHolderFactory = factory |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
484 treeItemManager = DWTreeItemManager() |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
485 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
486 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
487 // Constructor used to accept user custom DWTreeItemManager class |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
488 // @param factory a View Holder Factory mapped with layout id's |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
489 // @param manager a custom tree node manager class |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
490 constructor(factory: DWTreeViewHolderFactory, manager: DWTreeItemManager) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
491 treeViewHolderFactory = factory |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
492 treeItemManager = manager |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
493 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
494 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
495 override fun onCreateViewHolder(parent: ViewGroup, layoutId: Int): DWTreeViewHolder { |
2781
c28602443759
Android: Add DWTreeItemView class based on LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2777
diff
changeset
|
496 val view = DWTreeItemView(parent.context) |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
497 return treeViewHolderFactory.getTreeViewHolder(view, layoutId) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
498 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
499 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
500 override fun onBindViewHolder(holder: DWTreeViewHolder, position: Int) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
501 val currentNode: DWTreeItem = treeItemManager.get(position) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
502 holder.bindTreeItem(currentNode) |
2799
fd7c6ff72383
Android: Separate handling of expand/collapse when touched on the expandCollpaseView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2798
diff
changeset
|
503 val treeItemView = holder.itemView as DWTreeItemView |
fd7c6ff72383
Android: Separate handling of expand/collapse when touched on the expandCollpaseView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2798
diff
changeset
|
504 |
fd7c6ff72383
Android: Separate handling of expand/collapse when touched on the expandCollpaseView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2798
diff
changeset
|
505 // Handle touch on the expand/collapse image |
fd7c6ff72383
Android: Separate handling of expand/collapse when touched on the expandCollpaseView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2798
diff
changeset
|
506 treeItemView.expandCollapseView.setOnClickListener { v -> |
fd7c6ff72383
Android: Separate handling of expand/collapse when touched on the expandCollpaseView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2798
diff
changeset
|
507 // Handle node expand and collapse event |
fd7c6ff72383
Android: Separate handling of expand/collapse when touched on the expandCollpaseView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2798
diff
changeset
|
508 if (!currentNode.getChildren().isEmpty()) { |
fd7c6ff72383
Android: Separate handling of expand/collapse when touched on the expandCollpaseView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2798
diff
changeset
|
509 val isNodeExpanded: Boolean = currentNode.isExpanded() |
fd7c6ff72383
Android: Separate handling of expand/collapse when touched on the expandCollpaseView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2798
diff
changeset
|
510 if (isNodeExpanded) collapseNode(currentNode) else expandNode(currentNode) |
fd7c6ff72383
Android: Separate handling of expand/collapse when touched on the expandCollpaseView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2798
diff
changeset
|
511 currentNode.setExpanded(!isNodeExpanded) |
fd7c6ff72383
Android: Separate handling of expand/collapse when touched on the expandCollpaseView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2798
diff
changeset
|
512 |
fd7c6ff72383
Android: Separate handling of expand/collapse when touched on the expandCollpaseView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2798
diff
changeset
|
513 notifyDataSetChanged() |
fd7c6ff72383
Android: Separate handling of expand/collapse when touched on the expandCollpaseView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2798
diff
changeset
|
514 |
fd7c6ff72383
Android: Separate handling of expand/collapse when touched on the expandCollpaseView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2798
diff
changeset
|
515 // Handle DWTreeItem expand listener event |
fd7c6ff72383
Android: Separate handling of expand/collapse when touched on the expandCollpaseView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2798
diff
changeset
|
516 if (!isNodeExpanded && treeItemExpandListener != null) treeItemExpandListener!!( |
fd7c6ff72383
Android: Separate handling of expand/collapse when touched on the expandCollpaseView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2798
diff
changeset
|
517 currentNode, |
fd7c6ff72383
Android: Separate handling of expand/collapse when touched on the expandCollpaseView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2798
diff
changeset
|
518 v |
fd7c6ff72383
Android: Separate handling of expand/collapse when touched on the expandCollpaseView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2798
diff
changeset
|
519 ) |
fd7c6ff72383
Android: Separate handling of expand/collapse when touched on the expandCollpaseView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2798
diff
changeset
|
520 } |
fd7c6ff72383
Android: Separate handling of expand/collapse when touched on the expandCollpaseView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2798
diff
changeset
|
521 } |
fd7c6ff72383
Android: Separate handling of expand/collapse when touched on the expandCollpaseView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2798
diff
changeset
|
522 // Handle node selection |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
523 holder.itemView.setOnClickListener { v -> |
2799
fd7c6ff72383
Android: Separate handling of expand/collapse when touched on the expandCollpaseView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2798
diff
changeset
|
524 // If touched anywhere else, change the selection |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
525 currentNode.setSelected(true) |
2798
a3d62de81ec0
Android: Changes to highlight the selected node of the tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2797
diff
changeset
|
526 treeItemView.isChecked = true |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
527 currentSelectedItem?.setSelected(false) |
2798
a3d62de81ec0
Android: Changes to highlight the selected node of the tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2797
diff
changeset
|
528 currentSelectedItemView?.isChecked = false |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
529 currentSelectedItem = currentNode |
2798
a3d62de81ec0
Android: Changes to highlight the selected node of the tree widget.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2797
diff
changeset
|
530 currentSelectedItemView = treeItemView |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
531 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
532 notifyDataSetChanged() |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
533 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
534 // Handle DWTreeItem click listener event |
2785
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
535 if (treeItemClickListener != null) treeItemClickListener!!( |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
536 currentNode, |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
537 v |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
538 ) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
539 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
540 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
541 // Handle DWTreeItem long click listener event |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
542 holder.itemView.setOnLongClickListener { v -> |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
543 if (treeItemLongClickListener != null) { |
2785
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
544 return@setOnLongClickListener treeItemLongClickListener!!( |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
545 currentNode, |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
546 v |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
547 ) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
548 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
549 true |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
550 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
551 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
552 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
553 override fun getItemViewType(position: Int): Int { |
2783
1b7c1b6ee760
Android: Fix tree basic functionality... need to add child branches,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2782
diff
changeset
|
554 return 1 |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
555 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
556 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
557 override fun getItemCount(): Int { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
558 return treeItemManager.size() |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
559 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
560 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
561 // Collapsing node and all of his children |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
562 // @param node The node to collapse it |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
563 fun collapseNode(node: DWTreeItem) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
564 val position: Int = treeItemManager.collapseItem(node) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
565 if (position != -1) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
566 notifyDataSetChanged() |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
567 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
568 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
569 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
570 // Expanding node and all of his children |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
571 // @param node The node to expand it |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
572 fun expandNode(node: DWTreeItem) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
573 val position: Int = treeItemManager.expandItem(node) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
574 if (position != -1) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
575 notifyDataSetChanged() |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
576 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
577 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
578 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
579 // Collapsing full node branches |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
580 // @param node The node to collapse it |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
581 fun collapseNodeBranch(node: DWTreeItem) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
582 treeItemManager.collapseItemBranch(node) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
583 notifyDataSetChanged() |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
584 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
585 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
586 // Expanding node full branches |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
587 // @param node The node to expand it |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
588 fun expandNodeBranch(node: DWTreeItem) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
589 treeItemManager.expandItemBranch(node) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
590 notifyDataSetChanged() |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
591 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
592 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
593 // Expanding one node branch to until specific level |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
594 // @param node to expand branch of it until level |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
595 // @param level to expand node branches to it |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
596 fun expandNodeToLevel(node: DWTreeItem, level: Int) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
597 treeItemManager.expandItemToLevel(node, level) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
598 notifyDataSetChanged() |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
599 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
600 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
601 // Expanding all tree nodes branches to until specific level |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
602 // @param level to expand all nodes branches to it |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
603 fun expandNodesAtLevel(level: Int) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
604 treeItemManager.expandItemsAtLevel(level) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
605 notifyDataSetChanged() |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
606 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
607 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
608 // Collapsing all nodes in the tree with their children |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
609 fun collapseAll() { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
610 treeItemManager.collapseAll() |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
611 notifyDataSetChanged() |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
612 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
613 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
614 // Expanding all nodes in the tree with their children |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
615 fun expandAll() { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
616 treeItemManager.expandAll() |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
617 notifyDataSetChanged() |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
618 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
619 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
620 // Update the list of tree nodes |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
621 // @param treeItems The new tree nodes |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
622 fun updateTreeItems(treeItems: List<DWTreeItem>) { |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
623 treeItemManager.updateItems(treeItems) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
624 notifyItemRangeInserted(0, treeItems.size) |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
625 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
626 |
2777
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
627 // Clear all the items from the tree |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
628 fun clear() { |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
629 treeItemManager.clearItems() |
2783
1b7c1b6ee760
Android: Fix tree basic functionality... need to add child branches,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2782
diff
changeset
|
630 notifyDataSetChanged() |
2777
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
631 } |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
632 |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
633 // Register a callback to be invoked when this DWTreeItem is clicked |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
634 // @param listener The callback that will run |
2785
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
635 fun setTreeItemClickListener(listener: (DWTreeItem?, View?) -> Boolean) { |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
636 treeItemClickListener = listener |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
637 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
638 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
639 // Register a callback to be invoked when this DWTreeItem is clicked and held |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
640 // @param listener The callback that will run |
2785
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
641 fun setTreeItemLongClickListener(listener: (DWTreeItem?, View?) -> Boolean) { |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
642 treeItemLongClickListener = listener |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
643 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
644 |
2785
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
645 // Register a callback to be invoked when this DWTreeItem is expanded |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
646 // @param listener The callback that will run |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
647 fun setTreeItemExpandListener(listener: (DWTreeItem?, View?) -> Boolean) { |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
648 treeItemExpandListener = listener |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
649 } |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
650 |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
651 // @return The current selected DWTreeItem |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
652 val selectedNode: DWTreeItem? |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
653 get() = currentSelectedItem |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
654 } |
2713
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
655 |
2775
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
656 class DWTree(context: Context) : RecyclerView(context) |
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
657 { |
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
658 var roots: MutableList<DWTreeItem> = ArrayList() |
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
659 |
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
660 fun updateTree() |
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
661 { |
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
662 val treeViewAdapter = this.adapter as DWTreeViewAdapter |
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
663 |
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
664 treeViewAdapter.updateTreeItems(roots) |
2783
1b7c1b6ee760
Android: Fix tree basic functionality... need to add child branches,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2782
diff
changeset
|
665 treeViewAdapter.notifyDataSetChanged() |
2775
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
666 } |
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
667 } |
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
668 |
2713
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
669 // Color Wheel section |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
670 private val HUE_COLORS = intArrayOf( |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
671 Color.RED, |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
672 Color.YELLOW, |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
673 Color.GREEN, |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
674 Color.CYAN, |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
675 Color.BLUE, |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
676 Color.MAGENTA, |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
677 Color.RED |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
678 ) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
679 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
680 private val SATURATION_COLORS = intArrayOf( |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
681 Color.WHITE, |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
682 setAlpha(Color.WHITE, 0) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
683 ) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
684 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
685 open class ColorWheel @JvmOverloads constructor( |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
686 context: Context, |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
687 attrs: AttributeSet? = null, |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
688 defStyleAttr: Int = 0 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
689 ) : View(context, attrs, defStyleAttr) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
690 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
691 private val hueGradient = GradientDrawable().apply { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
692 gradientType = GradientDrawable.SWEEP_GRADIENT |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
693 shape = GradientDrawable.OVAL |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
694 colors = HUE_COLORS |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
695 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
696 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
697 private val saturationGradient = GradientDrawable().apply { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
698 gradientType = GradientDrawable.RADIAL_GRADIENT |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
699 shape = GradientDrawable.OVAL |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
700 colors = SATURATION_COLORS |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
701 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
702 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
703 private val thumbDrawable = ThumbDrawable() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
704 private val hsvColor = HsvColor(value = 1f) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
705 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
706 private var wheelCenterX = 0 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
707 private var wheelCenterY = 0 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
708 private var wheelRadius = 0 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
709 private var downX = 0f |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
710 private var downY = 0f |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
711 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
712 var rgb |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
713 get() = hsvColor.rgb |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
714 set(rgb) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
715 hsvColor.rgb = rgb |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
716 hsvColor.set(value = 1f) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
717 fireColorListener() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
718 invalidate() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
719 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
720 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
721 var thumbRadius |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
722 get() = thumbDrawable.radius |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
723 set(value) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
724 thumbDrawable.radius = value |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
725 invalidate() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
726 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
727 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
728 var thumbColor |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
729 get() = thumbDrawable.thumbColor |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
730 set(value) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
731 thumbDrawable.thumbColor = value |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
732 invalidate() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
733 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
734 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
735 var thumbStrokeColor |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
736 get() = thumbDrawable.strokeColor |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
737 set(value) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
738 thumbDrawable.strokeColor = value |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
739 invalidate() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
740 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
741 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
742 var thumbColorCircleScale |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
743 get() = thumbDrawable.colorCircleScale |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
744 set(value) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
745 thumbDrawable.colorCircleScale = value |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
746 invalidate() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
747 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
748 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
749 var colorChangeListener: ((Int) -> Unit)? = null |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
750 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
751 var interceptTouchEvent = true |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
752 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
753 init { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
754 thumbRadius = 13 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
755 thumbColor = Color.WHITE |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
756 thumbStrokeColor = Color.DKGRAY |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
757 thumbColorCircleScale = 0.7f |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
758 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
759 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
760 fun setRgb(r: Int, g: Int, b: Int) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
761 rgb = Color.rgb(r, g, b) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
762 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
763 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
764 override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
765 val minDimension = minOf( |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
766 MeasureSpec.getSize(widthMeasureSpec), |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
767 MeasureSpec.getSize(heightMeasureSpec) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
768 ) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
769 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
770 setMeasuredDimension( |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
771 resolveSize(minDimension, widthMeasureSpec), |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
772 resolveSize(minDimension, heightMeasureSpec) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
773 ) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
774 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
775 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
776 override fun onDraw(canvas: Canvas) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
777 drawColorWheel(canvas) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
778 drawThumb(canvas) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
779 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
780 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
781 private fun drawColorWheel(canvas: Canvas) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
782 val hSpace = width - paddingLeft - paddingRight |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
783 val vSpace = height - paddingTop - paddingBottom |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
784 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
785 wheelCenterX = paddingLeft + hSpace / 2 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
786 wheelCenterY = paddingTop + vSpace / 2 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
787 wheelRadius = maxOf(minOf(hSpace, vSpace) / 2, 0) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
788 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
789 val left = wheelCenterX - wheelRadius |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
790 val top = wheelCenterY - wheelRadius |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
791 val right = wheelCenterX + wheelRadius |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
792 val bottom = wheelCenterY + wheelRadius |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
793 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
794 hueGradient.setBounds(left, top, right, bottom) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
795 saturationGradient.setBounds(left, top, right, bottom) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
796 saturationGradient.gradientRadius = wheelRadius.toFloat() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
797 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
798 hueGradient.draw(canvas) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
799 saturationGradient.draw(canvas) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
800 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
801 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
802 private fun drawThumb(canvas: Canvas) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
803 val r = hsvColor.saturation * wheelRadius |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
804 val hueRadians = toRadians(hsvColor.hue) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
805 val x = cos(hueRadians) * r + wheelCenterX |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
806 val y = sin(hueRadians) * r + wheelCenterY |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
807 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
808 thumbDrawable.indicatorColor = hsvColor.rgb |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
809 thumbDrawable.setCoordinates(x, y) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
810 thumbDrawable.draw(canvas) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
811 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
812 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
813 override fun onTouchEvent(event: MotionEvent): Boolean { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
814 when (event.actionMasked) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
815 MotionEvent.ACTION_DOWN -> onActionDown(event) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
816 MotionEvent.ACTION_MOVE -> updateColorOnMotionEvent(event) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
817 MotionEvent.ACTION_UP -> { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
818 updateColorOnMotionEvent(event) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
819 if (isTap(event, downX, downY)) performClick() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
820 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
821 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
822 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
823 return true |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
824 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
825 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
826 private fun onActionDown(event: MotionEvent) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
827 parent.requestDisallowInterceptTouchEvent(interceptTouchEvent) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
828 updateColorOnMotionEvent(event) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
829 downX = event.x |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
830 downY = event.y |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
831 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
832 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
833 override fun performClick() = super.performClick() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
834 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
835 private fun updateColorOnMotionEvent(event: MotionEvent) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
836 calculateColor(event) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
837 fireColorListener() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
838 invalidate() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
839 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
840 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
841 private fun calculateColor(event: MotionEvent) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
842 val legX = event.x - wheelCenterX |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
843 val legY = event.y - wheelCenterY |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
844 val hypot = minOf(hypot(legX, legY), wheelRadius.toFloat()) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
845 val hue = (toDegrees(atan2(legY, legX)) + 360) % 360 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
846 val saturation = hypot / wheelRadius |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
847 hsvColor.set(hue, saturation, 1f) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
848 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
849 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
850 private fun fireColorListener() { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
851 colorChangeListener?.invoke(hsvColor.rgb) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
852 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
853 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
854 override fun onSaveInstanceState(): Parcelable { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
855 val superState = super.onSaveInstanceState() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
856 val thumbState = thumbDrawable.saveState() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
857 return ColorWheelState(superState, this, thumbState) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
858 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
859 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
860 override fun onRestoreInstanceState(state: Parcelable) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
861 if (state is ColorWheelState) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
862 super.onRestoreInstanceState(state.superState) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
863 readColorWheelState(state) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
864 } else { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
865 super.onRestoreInstanceState(state) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
866 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
867 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
868 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
869 private fun readColorWheelState(state: ColorWheelState) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
870 thumbDrawable.restoreState(state.thumbState) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
871 interceptTouchEvent = state.interceptTouchEvent |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
872 rgb = state.rgb |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
873 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
874 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
875 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
876 internal class ColorWheelState : View.BaseSavedState { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
877 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
878 val thumbState: ThumbDrawableState |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
879 val interceptTouchEvent: Boolean |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
880 val rgb: Int |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
881 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
882 constructor( |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
883 superState: Parcelable?, |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
884 view: ColorWheel, |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
885 thumbState: ThumbDrawableState |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
886 ) : super(superState) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
887 this.thumbState = thumbState |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
888 interceptTouchEvent = view.interceptTouchEvent |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
889 rgb = view.rgb |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
890 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
891 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
892 constructor(source: Parcel) : super(source) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
893 thumbState = source.readThumbState() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
894 interceptTouchEvent = source.readBooleanCompat() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
895 rgb = source.readInt() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
896 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
897 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
898 override fun writeToParcel(out: Parcel, flags: Int) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
899 super.writeToParcel(out, flags) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
900 out.writeThumbState(thumbState, flags) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
901 out.writeBooleanCompat(interceptTouchEvent) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
902 out.writeInt(rgb) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
903 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
904 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
905 companion object CREATOR : Parcelable.Creator<ColorWheelState> { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
906 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
907 override fun createFromParcel(source: Parcel) = ColorWheelState(source) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
908 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
909 override fun newArray(size: Int) = arrayOfNulls<ColorWheelState>(size) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
910 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
911 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
912 internal fun Parcel.writeBooleanCompat(value: Boolean) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
913 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
914 this.writeBoolean(value) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
915 } else { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
916 this.writeInt(if (value) 1 else 0) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
917 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
918 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
919 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
920 internal fun Parcel.readBooleanCompat(): Boolean { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
921 return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
922 this.readBoolean() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
923 } else { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
924 this.readInt() == 1 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
925 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
926 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
927 private const val MAX_ALPHA = 255 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
928 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
929 open class GradientSeekBar @JvmOverloads constructor( |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
930 context: Context, |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
931 attrs: AttributeSet? = null, |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
932 defStyleAttr: Int = 0 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
933 ) : View(context, attrs, defStyleAttr) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
934 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
935 private val gradientColors = IntArray(2) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
936 private val thumbDrawable = ThumbDrawable() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
937 private val gradientDrawable = GradientDrawable() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
938 private val argbEvaluator = android.animation.ArgbEvaluator() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
939 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
940 private lateinit var orientationStrategy: OrientationStrategy |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
941 private var downX = 0f |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
942 private var downY = 0f |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
943 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
944 var startColor |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
945 get() = gradientColors[0] |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
946 set(color) { setColors(start = color) } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
947 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
948 var endColor |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
949 get() = gradientColors[1] |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
950 set(color) { setColors(end = color) } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
951 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
952 var offset = 0f |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
953 set(offset) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
954 field = ensureOffsetWithinRange(offset) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
955 calculateArgb() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
956 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
957 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
958 var barSize = 0 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
959 set(width) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
960 field = width |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
961 requestLayout() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
962 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
963 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
964 var cornersRadius = 0f |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
965 set(radius) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
966 field = radius |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
967 invalidate() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
968 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
969 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
970 var orientation = Orientation.VERTICAL |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
971 set(orientation) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
972 field = orientation |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
973 orientationStrategy = createOrientationStrategy() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
974 requestLayout() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
975 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
976 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
977 var thumbColor |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
978 get() = thumbDrawable.thumbColor |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
979 set(value) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
980 thumbDrawable.thumbColor = value |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
981 invalidate() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
982 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
983 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
984 var thumbStrokeColor |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
985 get() = thumbDrawable.strokeColor |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
986 set(value) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
987 thumbDrawable.strokeColor = value |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
988 invalidate() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
989 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
990 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
991 var thumbColorCircleScale |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
992 get() = thumbDrawable.colorCircleScale |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
993 set(value) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
994 thumbDrawable.colorCircleScale = value |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
995 invalidate() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
996 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
997 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
998 var thumbRadius |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
999 get() = thumbDrawable.radius |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1000 set(radius) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1001 thumbDrawable.radius = radius |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1002 requestLayout() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1003 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1004 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1005 var argb = 0 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1006 private set |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1007 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1008 var colorChangeListener: ((Float, Int) -> Unit)? = null |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1009 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1010 var interceptTouchEvent = true |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1011 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1012 init { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1013 thumbColor = Color.WHITE |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1014 thumbStrokeColor = Color.DKGRAY |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1015 thumbColorCircleScale = 0.7f |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1016 thumbRadius = 13 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1017 barSize = 10 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1018 cornersRadius = 5.0f |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1019 offset = 0f |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1020 orientation = Orientation.VERTICAL |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1021 setColors(Color.TRANSPARENT, Color.BLACK) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1022 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1023 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1024 private fun createOrientationStrategy(): OrientationStrategy { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1025 return when (orientation) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1026 Orientation.VERTICAL -> VerticalStrategy() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1027 Orientation.HORIZONTAL -> HorizontalStrategy() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1028 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1029 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1030 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1031 fun setColors(start: Int = startColor, end: Int = endColor) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1032 updateGradientColors(start, end) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1033 calculateArgb() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1034 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1035 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1036 private fun updateGradientColors(start: Int, end: Int) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1037 gradientColors[0] = start |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1038 gradientColors[1] = end |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1039 gradientDrawable.colors = gradientColors |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1040 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1041 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1042 override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1043 val dimens = orientationStrategy.measure(this, widthMeasureSpec, heightMeasureSpec) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1044 setMeasuredDimension(dimens.width(), dimens.height()) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1045 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1046 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1047 override fun onDraw(canvas: Canvas) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1048 drawGradientRect(canvas) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1049 drawThumb(canvas) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1050 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1051 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1052 private fun drawGradientRect(canvas: Canvas) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1053 gradientDrawable.orientation = orientationStrategy.gradientOrientation |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1054 gradientDrawable.bounds = orientationStrategy.getGradientBounds(this) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1055 gradientDrawable.cornerRadius = cornersRadius |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1056 gradientDrawable.draw(canvas) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1057 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1058 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1059 private fun drawThumb(canvas: Canvas) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1060 val coordinates = orientationStrategy.getThumbPosition(this, gradientDrawable.bounds) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1061 thumbDrawable.indicatorColor = argb |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1062 thumbDrawable.setCoordinates(coordinates.x, coordinates.y) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1063 thumbDrawable.draw(canvas) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1064 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1065 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1066 override fun onTouchEvent(event: MotionEvent): Boolean { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1067 when (event.actionMasked) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1068 MotionEvent.ACTION_DOWN -> onActionDown(event) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1069 MotionEvent.ACTION_MOVE -> calculateOffsetOnMotionEvent(event) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1070 MotionEvent.ACTION_UP -> { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1071 calculateOffsetOnMotionEvent(event) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1072 if (isTap(event, downX, downY)) performClick() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1073 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1074 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1075 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1076 return true |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1077 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1078 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1079 private fun onActionDown(event: MotionEvent) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1080 parent.requestDisallowInterceptTouchEvent(interceptTouchEvent) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1081 calculateOffsetOnMotionEvent(event) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1082 downX = event.x |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1083 downY = event.y |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1084 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1085 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1086 override fun performClick() = super.performClick() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1087 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1088 private fun calculateOffsetOnMotionEvent(event: MotionEvent) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1089 offset = orientationStrategy.getOffset(this, event, gradientDrawable.bounds) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1090 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1091 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1092 private fun calculateArgb() { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1093 argb = argbEvaluator.evaluate(offset, startColor, endColor) as Int |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1094 fireListener() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1095 invalidate() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1096 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1097 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1098 private fun fireListener() { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1099 colorChangeListener?.invoke(offset, argb) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1100 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1101 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1102 override fun onSaveInstanceState(): Parcelable { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1103 val superState = super.onSaveInstanceState() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1104 val thumbState = thumbDrawable.saveState() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1105 return GradientSeekBarState(superState, this, thumbState) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1106 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1107 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1108 override fun onRestoreInstanceState(state: Parcelable) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1109 if (state is GradientSeekBarState) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1110 super.onRestoreInstanceState(state.superState) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1111 readGradientSeekBarState(state) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1112 } else { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1113 super.onRestoreInstanceState(state) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1114 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1115 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1116 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1117 private fun readGradientSeekBarState(state: GradientSeekBarState) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1118 updateGradientColors(state.startColor, state.endColor) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1119 offset = state.offset |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1120 barSize = state.barSize |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1121 cornersRadius = state.cornerRadius |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1122 orientation = Orientation.values()[state.orientation] |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1123 interceptTouchEvent = state.interceptTouchEvent |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1124 thumbDrawable.restoreState(state.thumbState) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1125 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1126 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1127 private fun ensureOffsetWithinRange(offset: Float) = ensureWithinRange(offset, 0f, 1f) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1128 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1129 enum class Orientation { VERTICAL, HORIZONTAL } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1130 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1131 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1132 val GradientSeekBar.currentColorAlpha get() = Color.alpha(argb) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1133 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1134 fun GradientSeekBar.setTransparentToColor(color: Int, respectAlpha: Boolean = true) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1135 if (respectAlpha) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1136 this.offset = Color.alpha(color) / MAX_ALPHA.toFloat() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1137 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1138 this.setColors( |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1139 setAlpha(color, 0), |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1140 setAlpha(color, MAX_ALPHA) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1141 ) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1142 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1143 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1144 inline fun GradientSeekBar.setAlphaChangeListener( |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1145 crossinline listener: (Float, Int, Int) -> Unit |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1146 ) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1147 this.colorChangeListener = { offset, color -> |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1148 listener(offset, color, this.currentColorAlpha) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1149 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1150 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1151 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1152 fun GradientSeekBar.setBlackToColor(color: Int) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1153 this.setColors(Color.BLACK, color) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1154 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1155 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1156 internal class GradientSeekBarState : View.BaseSavedState { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1157 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1158 val startColor: Int |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1159 val endColor: Int |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1160 val offset: Float |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1161 val barSize: Int |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1162 val cornerRadius: Float |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1163 val orientation: Int |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1164 val interceptTouchEvent: Boolean |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1165 val thumbState: ThumbDrawableState |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1166 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1167 constructor( |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1168 superState: Parcelable?, |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1169 view: GradientSeekBar, |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1170 thumbState: ThumbDrawableState |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1171 ) : super(superState) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1172 startColor = view.startColor |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1173 endColor = view.endColor |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1174 offset = view.offset |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1175 barSize = view.barSize |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1176 cornerRadius = view.cornersRadius |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1177 orientation = view.orientation.ordinal |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1178 interceptTouchEvent = view.interceptTouchEvent |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1179 this.thumbState = thumbState |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1180 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1181 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1182 constructor(source: Parcel) : super(source) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1183 startColor = source.readInt() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1184 endColor = source.readInt() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1185 offset = source.readFloat() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1186 barSize = source.readInt() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1187 cornerRadius = source.readFloat() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1188 orientation = source.readInt() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1189 interceptTouchEvent = source.readBooleanCompat() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1190 thumbState = source.readThumbState() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1191 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1192 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1193 override fun writeToParcel(out: Parcel, flags: Int) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1194 super.writeToParcel(out, flags) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1195 out.writeInt(startColor) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1196 out.writeInt(endColor) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1197 out.writeFloat(offset) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1198 out.writeInt(barSize) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1199 out.writeFloat(cornerRadius) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1200 out.writeInt(orientation) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1201 out.writeBooleanCompat(interceptTouchEvent) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1202 out.writeThumbState(thumbState, flags) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1203 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1204 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1205 companion object CREATOR : Parcelable.Creator<GradientSeekBarState> { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1206 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1207 override fun createFromParcel(source: Parcel) = GradientSeekBarState(source) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1208 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1209 override fun newArray(size: Int) = arrayOfNulls<GradientSeekBarState>(size) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1210 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1211 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1212 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1213 internal class HorizontalStrategy : OrientationStrategy { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1214 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1215 private val rect = Rect() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1216 private val point = PointF() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1217 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1218 override val gradientOrientation = GradientDrawable.Orientation.LEFT_RIGHT |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1219 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1220 override fun measure(view: GradientSeekBar, widthSpec: Int, heightSpec: Int): Rect { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1221 val widthSize = View.MeasureSpec.getSize(widthSpec) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1222 val maxHeight = maxOf(view.barSize, view.thumbRadius * 2) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1223 val preferredWidth = widthSize + view.paddingLeft + view.paddingRight |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1224 val preferredHeight = maxHeight + view.paddingTop + view.paddingBottom |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1225 val finalWidth = View.resolveSize(preferredWidth, widthSpec) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1226 val finalHeight = View.resolveSize(preferredHeight, heightSpec) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1227 return rect.apply { set(0, 0, finalWidth, finalHeight) } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1228 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1229 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1230 override fun getGradientBounds(view: GradientSeekBar): Rect { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1231 val availableHeight = view.height - view.paddingTop - view.paddingRight |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1232 val left = view.paddingLeft + view.thumbRadius |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1233 val right = view.width - view.paddingRight - view.thumbRadius |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1234 val top = view.paddingTop + (availableHeight - view.barSize) / 2 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1235 val bottom = top + view.barSize |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1236 return rect.apply { set(left, top, right, bottom) } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1237 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1238 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1239 override fun getThumbPosition(view: GradientSeekBar, gradient: Rect): PointF { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1240 val x = (gradient.left + view.offset * gradient.width()) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1241 val y = view.height / 2f |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1242 return point.apply { set(x, y) } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1243 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1244 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1245 override fun getOffset(view: GradientSeekBar, event: MotionEvent, gradient: Rect): Float { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1246 val checkedX = ensureWithinRange(event.x.roundToInt(), gradient.left, gradient.right) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1247 val relativeX = (checkedX - gradient.left).toFloat() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1248 return relativeX / gradient.width() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1249 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1250 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1251 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1252 internal fun View.isTap(lastEvent: MotionEvent, initialX: Float, initialY: Float): Boolean { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1253 val config = ViewConfiguration.get(context) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1254 val duration = lastEvent.eventTime - lastEvent.downTime |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1255 val distance = hypot(lastEvent.x - initialX, lastEvent.y - initialY) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1256 return duration < ViewConfiguration.getTapTimeout() && distance < config.scaledTouchSlop |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1257 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1258 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1259 internal const val PI = Math.PI.toFloat() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1260 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1261 internal fun toRadians(degrees: Float) = degrees / 180f * PI |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1262 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1263 internal fun toDegrees(radians: Float) = radians * 180f / PI |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1264 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1265 internal fun <T> ensureWithinRange( |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1266 value: T, |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1267 start: T, |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1268 end: T |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1269 ): T where T : Number, T : Comparable<T> = minOf(maxOf(value, start), end) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1270 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1271 internal fun setAlpha(argb: Int, alpha: Int) = |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1272 Color.argb(alpha, Color.red(argb), Color.green(argb), Color.blue(argb)) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1273 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1274 class HsvColor(hue: Float = 0f, saturation: Float = 0f, value: Float = 0f) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1275 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1276 private val hsv = floatArrayOf( |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1277 ensureHue(hue), |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1278 ensureSaturation(saturation), |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1279 ensureValue(value) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1280 ) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1281 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1282 var hue |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1283 get() = hsv[0] |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1284 set(hue) { hsv[0] = ensureHue(hue) } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1285 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1286 var saturation |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1287 get() = hsv[1] |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1288 set(saturation) { hsv[1] = ensureSaturation(saturation) } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1289 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1290 var value |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1291 get() = hsv[2] |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1292 set(value) { hsv[2] = ensureValue(value) } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1293 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1294 var rgb |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1295 get() = Color.HSVToColor(hsv) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1296 set(rgb) { Color.colorToHSV(rgb, hsv) } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1297 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1298 fun set(hue: Float = hsv[0], saturation: Float = hsv[1], value: Float = hsv[2]) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1299 hsv[0] = ensureHue(hue) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1300 hsv[1] = ensureSaturation(saturation) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1301 hsv[2] = ensureValue(value) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1302 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1303 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1304 private fun ensureHue(hue: Float) = ensureWithinRange(hue, 0f, 360f) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1305 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1306 private fun ensureValue(value: Float) = ensureWithinRange(value, 0f, 1f) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1307 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1308 private fun ensureSaturation(saturation: Float) = ensureValue(saturation) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1309 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1310 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1311 internal interface OrientationStrategy { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1312 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1313 val gradientOrientation: GradientDrawable.Orientation |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1314 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1315 fun measure(view: GradientSeekBar, widthSpec: Int, heightSpec: Int): Rect |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1316 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1317 fun getGradientBounds(view: GradientSeekBar): Rect |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1318 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1319 fun getThumbPosition(view: GradientSeekBar, gradient: Rect): PointF |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1320 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1321 fun getOffset(view: GradientSeekBar, event: MotionEvent, gradient: Rect): Float |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1322 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1323 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1324 internal class ThumbDrawableState private constructor( |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1325 val radius: Int, |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1326 val thumbColor: Int, |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1327 val strokeColor: Int, |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1328 val colorCircleScale: Float |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1329 ) : Parcelable { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1330 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1331 constructor(thumbDrawable: ThumbDrawable) : this( |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1332 thumbDrawable.radius, |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1333 thumbDrawable.thumbColor, |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1334 thumbDrawable.strokeColor, |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1335 thumbDrawable.colorCircleScale |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1336 ) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1337 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1338 constructor(parcel: Parcel) : this( |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1339 parcel.readInt(), |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1340 parcel.readInt(), |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1341 parcel.readInt(), |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1342 parcel.readFloat() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1343 ) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1344 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1345 override fun writeToParcel(parcel: Parcel, flags: Int) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1346 parcel.writeInt(radius) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1347 parcel.writeInt(thumbColor) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1348 parcel.writeInt(strokeColor) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1349 parcel.writeFloat(colorCircleScale) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1350 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1351 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1352 override fun describeContents() = 0 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1353 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1354 companion object { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1355 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1356 val EMPTY_STATE = ThumbDrawableState(0, 0, 0, 0f) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1357 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1358 @JvmField |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1359 val CREATOR = object : Parcelable.Creator<ThumbDrawableState> { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1360 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1361 override fun createFromParcel(parcel: Parcel) = ThumbDrawableState(parcel) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1362 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1363 override fun newArray(size: Int) = arrayOfNulls<ThumbDrawableState>(size) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1364 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1365 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1366 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1367 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1368 internal fun Parcel.writeThumbState(state: ThumbDrawableState, flags: Int) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1369 this.writeParcelable(state, flags) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1370 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1371 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1372 internal fun Parcel.readThumbState(): ThumbDrawableState { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1373 return this.readParcelable(ThumbDrawableState::class.java.classLoader) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1374 ?: ThumbDrawableState.EMPTY_STATE |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1375 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1376 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1377 internal class ThumbDrawable { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1378 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1379 private val paint = Paint(Paint.ANTI_ALIAS_FLAG).apply { strokeWidth = 1f } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1380 private var x = 0f |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1381 private var y = 0f |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1382 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1383 var indicatorColor = 0 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1384 var strokeColor = 0 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1385 var thumbColor = 0 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1386 var radius = 0 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1387 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1388 var colorCircleScale = 0f |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1389 set(value) { field = ensureWithinRange(value, 0f, 1f) } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1390 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1391 fun setCoordinates(x: Float, y: Float) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1392 this.x = x |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1393 this.y = y |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1394 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1395 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1396 fun draw(canvas: Canvas) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1397 drawThumb(canvas) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1398 drawStroke(canvas) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1399 drawColorIndicator(canvas) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1400 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1401 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1402 private fun drawThumb(canvas: Canvas) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1403 paint.color = thumbColor |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1404 paint.style = Paint.Style.FILL |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1405 canvas.drawCircle(x, y, radius.toFloat(), paint) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1406 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1407 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1408 private fun drawStroke(canvas: Canvas) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1409 val strokeCircleRadius = radius - paint.strokeWidth / 2f |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1410 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1411 paint.color = strokeColor |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1412 paint.style = Paint.Style.STROKE |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1413 canvas.drawCircle(x, y, strokeCircleRadius, paint) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1414 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1415 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1416 private fun drawColorIndicator(canvas: Canvas) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1417 val colorIndicatorCircleRadius = radius * colorCircleScale |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1418 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1419 paint.color = indicatorColor |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1420 paint.style = Paint.Style.FILL |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1421 canvas.drawCircle(x, y, colorIndicatorCircleRadius, paint) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1422 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1423 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1424 fun restoreState(state: ThumbDrawableState) { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1425 radius = state.radius |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1426 thumbColor = state.thumbColor |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1427 strokeColor = state.strokeColor |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1428 colorCircleScale = state.colorCircleScale |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1429 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1430 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1431 fun saveState() = ThumbDrawableState(this) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1432 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1433 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1434 internal class VerticalStrategy : OrientationStrategy { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1435 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1436 private val rect = Rect() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1437 private val point = PointF() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1438 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1439 override val gradientOrientation = GradientDrawable.Orientation.BOTTOM_TOP |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1440 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1441 override fun measure(view: GradientSeekBar, widthSpec: Int, heightSpec: Int): Rect { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1442 val heightSize = View.MeasureSpec.getSize(heightSpec) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1443 val maxWidth = maxOf(view.barSize, view.thumbRadius * 2) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1444 val preferredWidth = maxWidth + view.paddingLeft + view.paddingRight |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1445 val preferredHeight = heightSize + view.paddingTop + view.paddingBottom |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1446 val finalWidth = View.resolveSize(preferredWidth, widthSpec) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1447 val finalHeight = View.resolveSize(preferredHeight, heightSpec) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1448 return rect.apply { set(0, 0, finalWidth, finalHeight) } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1449 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1450 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1451 override fun getGradientBounds(view: GradientSeekBar): Rect { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1452 val availableWidth = view.width - view.paddingLeft - view.paddingRight |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1453 val left = view.paddingLeft + (availableWidth - view.barSize) / 2 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1454 val right = left + view.barSize |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1455 val top = view.paddingTop + view.thumbRadius |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1456 val bottom = view.height - view.paddingBottom - view.thumbRadius |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1457 return rect.apply { set(left, top, right, bottom) } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1458 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1459 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1460 override fun getThumbPosition(view: GradientSeekBar, gradient: Rect): PointF { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1461 val y = (gradient.top + (1f - view.offset) * gradient.height()) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1462 val x = view.width / 2f |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1463 return point.apply { set(x, y) } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1464 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1465 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1466 override fun getOffset(view: GradientSeekBar, event: MotionEvent, gradient: Rect): Float { |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1467 val checkedY = ensureWithinRange(event.y.roundToInt(), gradient.top, gradient.bottom) |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1468 val relativeY = (checkedY - gradient.top).toFloat() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1469 return 1f - relativeY / gradient.height() |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1470 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1471 } |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1472 |
6594bb323ab5
Android: Import Colow Wheel by Anton Popov.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2709
diff
changeset
|
1473 // Main Dynamic Windows section |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
1474 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
|
1475 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
|
1476 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
|
1477 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
|
1478 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
|
1479 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
|
1480 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
|
1481 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
|
1482 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
|
1483 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
|
1484 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
|
1485 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
|
1486 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
|
1487 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
|
1488 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
|
1489 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
|
1490 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
|
1491 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
|
1492 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
|
1493 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
|
1494 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
|
1495 } |
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
1496 |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
1497 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
|
1498 |
2495
5664c91d03fb
Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2494
diff
changeset
|
1499 class DWTabViewPagerAdapter : RecyclerView.Adapter<DWTabViewPagerAdapter.DWEventViewHolder>() { |
2736
09775418c776
Android: Use "View" as the type for the viewList instead of LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2735
diff
changeset
|
1500 val viewList = mutableListOf<View>() |
2515
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1501 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
|
1502 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
|
1503 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
|
1504 var recyclerView: RecyclerView? = null |
2474
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
1505 |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
1506 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
|
1507 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
|
1508 |
2493
bca7e0ab0ccc
Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2492
diff
changeset
|
1509 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
|
1510 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
|
1511 return position |
4ae2b3b77f25
Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2497
diff
changeset
|
1512 } |
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
|
1513 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
|
1514 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
|
1515 } |
2495
5664c91d03fb
Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2494
diff
changeset
|
1516 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
|
1517 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
|
1518 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
1519 |
2498
4ae2b3b77f25
Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2497
diff
changeset
|
1520 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
|
1521 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
1522 |
2505
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
1523 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
|
1524 //Implement shouldOverrideUrlLoading// |
2788
8a4f162810c2
Android: During dw_file_browse() request read/write access to external
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2785
diff
changeset
|
1525 @Deprecated("Deprecated in Java") |
2505
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
1526 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
|
1527 // 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
|
1528 // 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
|
1529 return false |
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
1530 } |
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
1531 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
|
1532 // 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
|
1533 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
|
1534 } |
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
1535 |
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
1536 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
|
1537 // 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
|
1538 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
|
1539 } |
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
1540 |
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
1541 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
|
1542 } |
a149dabf6a1f
Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2503
diff
changeset
|
1543 |
2727
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1544 class DWPrintDocumentAdapter : PrintDocumentAdapter() |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1545 { |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1546 var context: Context? = null |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1547 var pages: Int = 0 |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1548 var pdfDocument: PrintedPdfDocument? = null |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1549 var print: Long = 0 |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1550 |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1551 override fun onLayout( |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1552 oldAttributes: PrintAttributes?, |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1553 newAttributes: PrintAttributes, |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1554 cancellationSignal: CancellationSignal?, |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1555 callback: LayoutResultCallback, |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1556 extras: Bundle? |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1557 ) { |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1558 // Create a new PdfDocument with the requested page attributes |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1559 pdfDocument = context?.let { PrintedPdfDocument(it, newAttributes) } |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1560 |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1561 // Respond to cancellation request |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1562 if (cancellationSignal?.isCanceled == true) { |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1563 callback.onLayoutCancelled() |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1564 return |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1565 } |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1566 |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1567 if (pages > 0) { |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1568 // Return print information to print framework |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1569 PrintDocumentInfo.Builder("print_output.pdf") |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1570 .setContentType(PrintDocumentInfo.CONTENT_TYPE_DOCUMENT) |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1571 .setPageCount(pages) |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1572 .build() |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1573 .also { info -> |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1574 // Content layout reflow is complete |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1575 callback.onLayoutFinished(info, true) |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1576 } |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1577 } else { |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1578 // Otherwise report an error to the print framework |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1579 callback.onLayoutFailed("No pages to print.") |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1580 } |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1581 } |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1582 |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1583 override fun onWrite( |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1584 pageRanges: Array<out PageRange>, |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1585 destination: ParcelFileDescriptor, |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1586 cancellationSignal: CancellationSignal?, |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1587 callback: WriteResultCallback |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1588 ) { |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1589 var writtenPagesArray: Array<PdfDocument.Page> = emptyArray() |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1590 |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1591 // Iterate over each page of the document, |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1592 // check if it's in the output range. |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1593 for (i in 0 until pages) { |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1594 pdfDocument?.startPage(i)?.also { page -> |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1595 |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1596 // check for cancellation |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1597 if (cancellationSignal?.isCanceled == true) { |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1598 callback.onWriteCancelled() |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1599 pdfDocument?.close() |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1600 pdfDocument = null |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1601 return |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1602 } |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1603 |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1604 // Draw page content for printing |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1605 var bitmap = Bitmap.createBitmap(page.canvas.width, page.canvas.height, Bitmap.Config.ARGB_8888) |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1606 // Actual drawing is done in the JNI C code callback to the bitmap |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1607 eventHandlerPrintDraw(print, bitmap, i, page.canvas.width, page.canvas.height) |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1608 // Copy from the bitmap canvas our C code drew on to the PDF page canvas |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1609 val rect = Rect(0, 0, page.canvas.width, page.canvas.height) |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1610 page.canvas.drawBitmap(bitmap, rect, rect, null) |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1611 |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1612 // Rendering is complete, so page can be finalized. |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1613 pdfDocument?.finishPage(page) |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1614 |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1615 // Add the new page to the array |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1616 writtenPagesArray += page |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1617 } |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1618 } |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1619 |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1620 // Write PDF document to file |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1621 try { |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1622 pdfDocument?.writeTo(FileOutputStream(destination.fileDescriptor)) |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1623 } catch (e: IOException) { |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1624 callback.onWriteFailed(e.toString()) |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1625 return |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1626 } finally { |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1627 pdfDocument?.close() |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1628 pdfDocument = null |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1629 } |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1630 // Signal the print framework the document is complete |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1631 callback.onWriteFinished(pageRanges) |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1632 } |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1633 |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1634 override fun onFinish() { |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1635 // Notify our C code so it can cleanup |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1636 eventHandlerPrintFinish(print) |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1637 super.onFinish() |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1638 } |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1639 |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1640 external fun eventHandlerPrintDraw(print: Long, bitmap: Bitmap, page: Int, width: Int, height: Int) |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1641 external fun eventHandlerPrintFinish(print: Long) |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1642 } |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
1643 |
2720
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
1644 class DWSlider |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
1645 @JvmOverloads constructor(context: Context): FrameLayout(context) { |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
1646 val slider: SeekBar = SeekBar(context) |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
1647 |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
1648 init { |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
1649 slider.layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
1650 LayoutParams.WRAP_CONTENT, Gravity.CENTER) |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
1651 addView(slider) |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
1652 } |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
1653 |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
1654 @Synchronized |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
1655 override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
1656 if(slider.rotation == 90F || slider.rotation == 270F) { |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
1657 val layoutHeight = MeasureSpec.getSize(heightMeasureSpec) |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
1658 // set slider width to layout heigth |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
1659 slider.layoutParams.width = layoutHeight |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
1660 } |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
1661 super.onMeasure(widthMeasureSpec, heightMeasureSpec) |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
1662 if(slider.rotation == 90F || slider.rotation == 270F) { |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
1663 // update layout width to the rotated height of the slider |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
1664 // otherwise the layout remains quadratic |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
1665 setMeasuredDimension(slider.measuredHeight, measuredHeight) |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
1666 } |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
1667 } |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
1668 } |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
1669 |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1670 class DWSpinButton(context: Context) : AppCompatEditText(context), OnTouchListener { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1671 var value: Long = 0 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1672 var minimum: Long = 0 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1673 var maximum: Long = 65535 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1674 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1675 init { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
1676 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
|
1677 setOnTouchListener(this) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1678 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1679 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1680 override fun onTouch(v: View, event: MotionEvent): Boolean { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1681 val DRAWABLE_RIGHT = 2 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1682 val DRAWABLE_LEFT = 0 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1683 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1684 if (event.action == MotionEvent.ACTION_UP) { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1685 if (event.x >= v.width - (v as EditText) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1686 .compoundDrawables[DRAWABLE_RIGHT].bounds.width() |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1687 ) { |
2527
eec926265888
Android: Use toLongOrNull() whenever converting from string to long...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2526
diff
changeset
|
1688 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
|
1689 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1690 if(newvalue != null) { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1691 value = newvalue + 1 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1692 } else { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1693 value += 1 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1694 } |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1695 if(value > maximum) { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1696 value = maximum |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1697 } |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1698 if(value < minimum) { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1699 value = minimum |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1700 } |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1701 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
|
1702 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
|
1703 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
|
1704 } 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
|
1705 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
|
1706 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1707 if(newvalue != null) { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1708 value = newvalue - 1 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1709 } else { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1710 value -= 1 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1711 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1712 if(value > maximum) { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1713 value = maximum |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
1714 } |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1715 if(value < minimum) { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1716 value = minimum |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1717 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1718 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
|
1719 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
|
1720 return true |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1721 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1722 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1723 return false |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1724 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1725 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1726 external fun eventHandlerInt( |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1727 message: Int, |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1728 inta: Int, |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1729 intb: Int, |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1730 intc: Int, |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1731 intd: Int |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1732 ) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1733 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1734 |
2515
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1735 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
|
1736 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
|
1737 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
|
1738 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
|
1739 |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1740 init { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
1741 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
|
1742 setOnTouchListener(this) |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1743 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
|
1744 lpw!!.setAdapter( |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1745 ArrayAdapter( |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1746 context, |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
1747 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
|
1748 ) |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1749 ) |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1750 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
|
1751 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
|
1752 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
|
1753 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1754 |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1755 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
|
1756 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
|
1757 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
|
1758 setText(item) |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1759 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
|
1760 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
|
1761 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1762 |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1763 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
|
1764 val DRAWABLE_RIGHT = 2 |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
1765 |
2515
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1766 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
|
1767 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
|
1768 .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
|
1769 ) { |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1770 lpw!!.show() |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1771 return true |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1772 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1773 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1774 return false |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1775 } |
2517
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1776 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1777 external fun eventHandlerInt( |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1778 message: Int, |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1779 inta: Int, |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1780 intb: Int, |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1781 intc: Int, |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1782 intd: Int |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
1783 ) |
2515
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1784 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
1785 |
2519
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1786 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
|
1787 var list = mutableListOf<String>() |
2753
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
1788 var multiple = mutableListOf<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
|
1789 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
|
1790 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
|
1791 var colorBack: Int? = null |
2753
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
1792 var colorSelected: Int = Color.DKGRAY |
2519
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1793 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1794 init { |
2753
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
1795 adapter = 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
|
1796 context, |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
1797 R.layout.simple_list_item_1, list |
2753
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
1798 ) { |
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
1799 override fun getView(pos: Int, view: View?, parent: ViewGroup): View { |
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
1800 val thisview = super.getView(pos, view, parent) |
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
1801 val textview = thisview as TextView |
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
1802 if (colorFore != null) { |
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
1803 textview.setTextColor(colorFore!!) |
2677
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
1804 } |
2753
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
1805 if (colorBack != null) { |
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
1806 textview.setBackgroundColor(colorBack!!) |
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
1807 } |
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
1808 return thisview |
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
1809 } |
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
1810 } |
2756
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
1811 colorSelected = getPlatformSelectionColor(context) |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
1812 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
|
1813 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1814 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1815 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
|
1816 selected = position |
2753
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
1817 if(this.choiceMode == ListView.CHOICE_MODE_MULTIPLE) { |
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
1818 if(multiple.contains(position)) { |
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
1819 multiple.remove(position) |
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
1820 view.setBackgroundColor(Color.TRANSPARENT) |
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
1821 } else { |
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
1822 multiple.add(position) |
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
1823 view.setBackgroundColor(colorSelected) |
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
1824 } |
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
1825 } |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
1826 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
|
1827 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1828 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1829 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
|
1830 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
|
1831 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
|
1832 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
|
1833 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
|
1834 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
|
1835 ) |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1836 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
1837 |
2530
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1838 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
|
1839 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
|
1840 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
|
1841 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
|
1842 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
|
1843 var evy: Float = 0f |
2611
ed2c4a503666
Android: Implement button release and motion notify events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2608
diff
changeset
|
1844 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
|
1845 |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1846 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
|
1847 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
|
1848 // 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
|
1849 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
|
1850 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1851 |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1852 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
|
1853 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
|
1854 cachedCanvas = canvas |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1855 // 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
|
1856 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
|
1857 cachedCanvas = null |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1858 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1859 |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1860 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
|
1861 message: Int, |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1862 inta: Int, |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1863 intb: Int, |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1864 intc: Int, |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1865 intd: Int |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1866 ) |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1867 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
1868 |
2526
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1869 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
|
1870 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
|
1871 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
|
1872 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
|
1873 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1874 // 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
|
1875 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
|
1876 fun setExtension(extension: String?) { |
2708
3a7dcc0ae08b
Android: Implement dw_mle_search(). Also revert lowercase() change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2707
diff
changeset
|
1877 this.extension = extension?.toLowerCase(Locale.ROOT) |
2526
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1878 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1879 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1880 // 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
|
1881 interface FileSelectedListener { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1882 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
|
1883 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1884 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1885 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
|
1886 this.fileListener = fileListener |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1887 return this |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1888 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1889 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1890 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
|
1891 fun showDialog() { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1892 dialog.show() |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1893 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1894 |
2527
eec926265888
Android: Use toLongOrNull() whenever converting from string to long...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2526
diff
changeset
|
1895 /* |
2526
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1896 * 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
|
1897 */ |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1898 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
|
1899 currentPath = path |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1900 if (path != null) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1901 if (path.exists()) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1902 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
|
1903 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
|
1904 if (!file.isDirectory) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1905 if (!file.canRead()) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1906 false |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1907 } 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
|
1908 true |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1909 } else { |
2708
3a7dcc0ae08b
Android: Implement dw_mle_search(). Also revert lowercase() change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2707
diff
changeset
|
1910 file.name.toLowerCase(Locale.ROOT).endsWith(extension!!) |
2526
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1911 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1912 } else { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1913 false |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1914 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1915 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1916 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1917 // 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
|
1918 var i = 0 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1919 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
|
1920 var filecount = 0 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1921 var dircount = 0 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1922 if(files != null) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1923 filecount = files.size |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1924 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1925 if(dirs != null) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1926 dircount = dirs.size |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1927 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1928 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
|
1929 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
|
1930 } else { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1931 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
|
1932 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
|
1933 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1934 if(dirs != null) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1935 Arrays.sort(dirs) |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1936 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
|
1937 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
|
1938 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1939 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1940 if(files != null) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1941 Arrays.sort(files) |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1942 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
|
1943 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
|
1944 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1945 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1946 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1947 // 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
|
1948 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
|
1949 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
|
1950 activity, |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1951 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
|
1952 ) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1953 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
|
1954 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
|
1955 (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
|
1956 return thisview |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1957 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1958 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1959 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1960 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1961 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1962 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1963 /** |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1964 * 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
|
1965 */ |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1966 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
|
1967 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
|
1968 currentPath!!.parentFile |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1969 } else { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1970 File(currentPath, fileChosen) |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1971 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1972 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1973 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1974 companion object { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1975 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
|
1976 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1977 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1978 init { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1979 list.onItemClickListener = |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1980 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
|
1981 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
|
1982 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
|
1983 if (chosenFile != null) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1984 if (chosenFile.isDirectory) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1985 refresh(chosenFile) |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1986 } else { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1987 if (fileListener != null) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1988 fileListener!!.fileSelected(chosenFile) |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1989 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1990 dialog.dismiss() |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1991 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1992 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1993 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1994 dialog.setContentView(list) |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1995 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
|
1996 refresh(Environment.getExternalStorageDirectory()) |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1997 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1998 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
1999 |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2000 // 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
|
2001 // 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
|
2002 // 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
|
2003 class DWMenuItem |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2004 { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2005 var title: String? = null |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2006 var menu: DWMenu? = null |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2007 var submenu: DWMenu? = null |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2008 var checked: Boolean = false |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2009 var check: Boolean = false |
2546
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
2010 var enabled: Boolean = true |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2011 var menuitem: MenuItem? = null |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2012 var submenuitem: SubMenu? = null |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2013 var id: Int = 0 |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2014 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2015 |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2016 class DWMenu { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2017 var menu: Menu? = null |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2018 var children = mutableListOf<DWMenuItem>() |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2019 var id: Int = 0 |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2020 |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2021 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
|
2022 var refresh = recreate |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2023 |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2024 if(newmenu != null) { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2025 if(newmenu != menu) { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2026 menu = newmenu |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2027 refresh = true |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2028 } |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2029 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2030 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
|
2031 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
|
2032 |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2033 if(refresh) { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2034 menu!!.clear() |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2035 } |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2036 |
2544
dbfcc0e357d6
Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2543
diff
changeset
|
2037 // Enable group dividers for separators |
2788
8a4f162810c2
Android: During dw_file_browse() request read/write access to external
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2785
diff
changeset
|
2038 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
|
2039 |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2040 for (menuitem in children) { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2041 // 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
|
2042 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
|
2043 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
|
2044 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
|
2045 } |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2046 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
|
2047 } 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
|
2048 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
|
2049 group += 1 |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2050 } 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
|
2051 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
|
2052 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
|
2053 menuitem.menuitem!!.isChecked = menuitem.checked |
2546
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
2054 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
|
2055 menuitem.menuitem!!.setOnMenuItemClickListener { item: MenuItem? -> |
2806
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
2056 // Toggle the check automatically |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
2057 if(menuitem.menuitem!!.isCheckable) { |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
2058 menuitem.menuitem!!.isChecked = !menuitem.menuitem!!.isChecked |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
2059 menuitem.checked = menuitem.menuitem!!.isChecked |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
2060 } |
2620
dcd71b04cc46
Android: Add internal event constants for more clarity about what code does.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2614
diff
changeset
|
2061 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
|
2062 true |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
2063 } |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2064 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2065 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2066 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2067 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2068 } |
2544
dbfcc0e357d6
Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2543
diff
changeset
|
2069 |
dbfcc0e357d6
Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2543
diff
changeset
|
2070 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
|
2071 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2072 |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2073 // Class for storing container data |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2074 class DWContainerModel { |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2075 var columns = mutableListOf<String?>() |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2076 var types = mutableListOf<Int>() |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2077 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
|
2078 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
|
2079 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
|
2080 var querypos: Int = -1 |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2081 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2082 fun numberOfColumns(): Int |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2083 { |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2084 return columns.size |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2085 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2086 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2087 fun numberOfRows(): Int |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2088 { |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
2089 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
|
2090 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
|
2091 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
2092 return 0 |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2093 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2094 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2095 fun getColumnType(column: Int): Int |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2096 { |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2097 if(column < types.size) { |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2098 return types[column] |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2099 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2100 return -1 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2101 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2102 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2103 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
|
2104 { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2105 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
|
2106 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2107 if(index > -1 && index < data.size) { |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2108 return data[index] |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2109 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2110 return null |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2111 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2112 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2113 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
|
2114 { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2115 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
|
2116 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2117 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
|
2118 // 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
|
2119 if((((types[column] and 1) != 0) && (obj is Drawable)) || |
2834
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2120 (((types[column] and (1 shl 2)) != 0) && (obj is Int || obj is Long))) { |
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2121 data[index] = obj |
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2122 } |
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2123 // If it isn't one of those special types, image or numeric...use string |
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2124 else if(((types[column] and 1) == 0) && ((types[column] and (1 shl 2)) == 0) |
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2125 && obj is String) { |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2126 data[index] = obj |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2127 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2128 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2129 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2130 |
2558
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2131 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
|
2132 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2133 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
|
2134 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
|
2135 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2136 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2137 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2138 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
|
2139 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2140 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
|
2141 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
|
2142 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2143 return 0 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2144 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2145 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2146 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
|
2147 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2148 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
|
2149 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
|
2150 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2151 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2152 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2153 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
|
2154 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2155 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
|
2156 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
|
2157 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2158 return null |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2159 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2160 |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2161 fun addColumn(title: String?, type: Int) |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2162 { |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2163 columns.add(title) |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2164 types.add(type) |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2165 // 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
|
2166 data.clear() |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2167 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2168 |
2558
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2169 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
|
2170 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2171 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
|
2172 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
|
2173 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
|
2174 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
|
2175 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2176 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
|
2177 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
|
2178 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2179 } else { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2180 data.clear() |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2181 rowdata.clear() |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2182 rowtitle.clear() |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2183 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2184 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2185 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2186 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
|
2187 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2188 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
|
2189 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
|
2190 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
|
2191 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
|
2192 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2193 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
|
2194 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
|
2195 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2196 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2197 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2198 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2199 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
|
2200 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2201 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
|
2202 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
|
2203 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
|
2204 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
|
2205 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2206 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
|
2207 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
|
2208 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2209 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2210 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2211 |
2709
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
2212 fun positionByTitle(title: String?): Int |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
2213 { |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
2214 for(i in 0 until rowtitle.size) { |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
2215 if(rowtitle[i] != null && rowtitle[i] == title) { |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
2216 return i |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
2217 } |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
2218 } |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
2219 return -1 |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
2220 } |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
2221 |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
2222 fun positionByData(rdata: Long): Int |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
2223 { |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
2224 for(i in 0 until rowdata.size) { |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
2225 if (rowdata[i] == rdata) { |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
2226 return i |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
2227 } |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
2228 } |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
2229 return -1 |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
2230 } |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
2231 |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
2232 fun addRows(count: Int): Long |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2233 { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2234 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
|
2235 |
2558
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2236 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
|
2237 { |
2558
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2238 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
|
2239 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2240 // 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
|
2241 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
|
2242 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2243 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
|
2244 rowtitle.add(null) |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2245 } |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
2246 return startRow |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2247 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2248 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2249 fun clear() |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2250 { |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2251 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
|
2252 rowdata.clear() |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
2253 rowtitle.clear() |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2254 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2255 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2256 |
2841
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2257 class DWContainerRow : RelativeLayout, Checkable { |
2752
d355c6abbba6
Android: Add a DWContainerRow class implmenting LinearLayout and Checkable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2751
diff
changeset
|
2258 private var mChecked = false |
2756
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2259 private var colorSelection = Color.DKGRAY |
2841
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2260 var imageview: ImageView = ImageView(context) |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2261 var text: TextView = TextView(context) |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2262 var stack: LinearLayout = LinearLayout(context) |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2263 |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2264 fun setup(context: Context?) { |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2265 val wrap = RelativeLayout.LayoutParams.WRAP_CONTENT |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2266 val match = RelativeLayout.LayoutParams.MATCH_PARENT |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2267 var lp = RelativeLayout.LayoutParams(wrap, wrap) |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2268 imageview.id = View.generateViewId() |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2269 this.addView(imageview, lp) |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2270 lp = RelativeLayout.LayoutParams(match, wrap) |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2271 text.id = View.generateViewId() |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2272 lp.addRule(RelativeLayout.RIGHT_OF, imageview.id); |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2273 this.addView(text, lp) |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2274 lp = RelativeLayout.LayoutParams(match, wrap) |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2275 stack.id = View.generateViewId() |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2276 stack.orientation = LinearLayout.HORIZONTAL |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2277 lp.addRule(RelativeLayout.BELOW, imageview.id); |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2278 lp.addRule(RelativeLayout.BELOW, text.id); |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2279 this.addView(stack, lp) |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2280 } |
2756
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2281 |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2282 constructor(context: Context?) : super(context) { |
2841
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2283 setup(context) |
2756
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2284 colorSelection = context?.let { getPlatformSelectionColor(it) }!! |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2285 } |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2286 constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) { |
2841
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2287 setup(context) |
2756
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2288 colorSelection = context?.let { getPlatformSelectionColor(it) }!! |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2289 } |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2290 constructor(context: Context?, attrs: AttributeSet?, defStyle: Int) : super(context, attrs, defStyle) { |
2841
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2291 setup(context) |
2756
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2292 colorSelection = context?.let { getPlatformSelectionColor(it) }!! |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2293 } |
2752
d355c6abbba6
Android: Add a DWContainerRow class implmenting LinearLayout and Checkable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2751
diff
changeset
|
2294 |
2754
e256bd8628ba
Andrdoi: Attempt to fix a number of issues querying containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2753
diff
changeset
|
2295 fun updateBackground() { |
e256bd8628ba
Andrdoi: Attempt to fix a number of issues querying containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2753
diff
changeset
|
2296 if(mChecked) { |
2756
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2297 this.setBackgroundColor(colorSelection) |
2754
e256bd8628ba
Andrdoi: Attempt to fix a number of issues querying containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2753
diff
changeset
|
2298 } else { |
e256bd8628ba
Andrdoi: Attempt to fix a number of issues querying containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2753
diff
changeset
|
2299 this.setBackgroundColor(Color.TRANSPARENT) |
e256bd8628ba
Andrdoi: Attempt to fix a number of issues querying containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2753
diff
changeset
|
2300 } |
e256bd8628ba
Andrdoi: Attempt to fix a number of issues querying containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2753
diff
changeset
|
2301 } |
e256bd8628ba
Andrdoi: Attempt to fix a number of issues querying containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2753
diff
changeset
|
2302 |
2752
d355c6abbba6
Android: Add a DWContainerRow class implmenting LinearLayout and Checkable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2751
diff
changeset
|
2303 override fun setChecked(b: Boolean) { |
d355c6abbba6
Android: Add a DWContainerRow class implmenting LinearLayout and Checkable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2751
diff
changeset
|
2304 mChecked = b |
2754
e256bd8628ba
Andrdoi: Attempt to fix a number of issues querying containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2753
diff
changeset
|
2305 updateBackground() |
2752
d355c6abbba6
Android: Add a DWContainerRow class implmenting LinearLayout and Checkable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2751
diff
changeset
|
2306 } |
d355c6abbba6
Android: Add a DWContainerRow class implmenting LinearLayout and Checkable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2751
diff
changeset
|
2307 |
d355c6abbba6
Android: Add a DWContainerRow class implmenting LinearLayout and Checkable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2751
diff
changeset
|
2308 override fun isChecked(): Boolean { |
d355c6abbba6
Android: Add a DWContainerRow class implmenting LinearLayout and Checkable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2751
diff
changeset
|
2309 return mChecked |
d355c6abbba6
Android: Add a DWContainerRow class implmenting LinearLayout and Checkable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2751
diff
changeset
|
2310 } |
d355c6abbba6
Android: Add a DWContainerRow class implmenting LinearLayout and Checkable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2751
diff
changeset
|
2311 |
d355c6abbba6
Android: Add a DWContainerRow class implmenting LinearLayout and Checkable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2751
diff
changeset
|
2312 override fun toggle() { |
d355c6abbba6
Android: Add a DWContainerRow class implmenting LinearLayout and Checkable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2751
diff
changeset
|
2313 mChecked = !mChecked |
2754
e256bd8628ba
Andrdoi: Attempt to fix a number of issues querying containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2753
diff
changeset
|
2314 updateBackground() |
2752
d355c6abbba6
Android: Add a DWContainerRow class implmenting LinearLayout and Checkable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2751
diff
changeset
|
2315 } |
d355c6abbba6
Android: Add a DWContainerRow class implmenting LinearLayout and Checkable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2751
diff
changeset
|
2316 } |
d355c6abbba6
Android: Add a DWContainerRow class implmenting LinearLayout and Checkable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2751
diff
changeset
|
2317 |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2318 class DWContainerAdapter(c: Context) : BaseAdapter() |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2319 { |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2320 private var context = c |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2321 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
|
2322 var selectedItem: Int = -1 |
2834
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2323 var contMode: Int = 0 |
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
|
2324 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
|
2325 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
|
2326 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
|
2327 var backColor: Int? = null |
2613
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
2328 var lastClick: Long = 0 |
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
2329 var lastClickRow: Int = -1 |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2330 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2331 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
|
2332 return model.numberOfRows() |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2333 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2334 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2335 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
|
2336 return model.getRowAndColumn(position, 0) |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2337 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2338 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2339 override fun getItemId(position: Int): Long { |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2340 return position.toLong() |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2341 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2342 |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2343 override fun getView(position: Int, view: View?, parent: ViewGroup): View { |
2752
d355c6abbba6
Android: Add a DWContainerRow class implmenting LinearLayout and Checkable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2751
diff
changeset
|
2344 var rowView: DWContainerRow? = view as DWContainerRow? |
2565
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
2345 var displayColumns = model.numberOfColumns() |
2835
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2346 var isFilesystem: Boolean = false |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2347 var extraColumns: Int = 1 |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2348 |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2349 // If column 1 is bitmap and column 2 is text... |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2350 if(displayColumns > 1 && (model.getColumnType(0) and 1) != 0 && |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2351 (model.getColumnType(1) and (1 shl 1)) != 0) { |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2352 // We are a filesystem style container... |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2353 isFilesystem = true |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2354 extraColumns = 2 |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2355 } |
2565
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
2356 |
2834
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2357 // In default mode (0), limit the columns to 1 or 2 |
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2358 if(contMode == 0) { |
2835
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2359 // depending on if we are filesystem style or not |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2360 displayColumns = extraColumns |
2565
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
2361 } |
2561
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
2362 |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
2363 // 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
|
2364 if(rowView == null) { |
2752
d355c6abbba6
Android: Add a DWContainerRow class implmenting LinearLayout and Checkable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2751
diff
changeset
|
2365 rowView = DWContainerRow(context) |
2565
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
2366 |
2834
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2367 // Handle DW_CONTAINER_MODE_MULTI by setting the orientation vertical |
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2368 if(contMode == 2) { |
2841
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2369 rowView.stack.orientation = LinearLayout.VERTICAL |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2370 rowView.stack.gravity = Gravity.LEFT |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2371 } |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2372 |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2373 // If there are extra columns and we are not in default mode... |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2374 // Add the columns to the stack (LinearLayout) |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2375 for(i in extraColumns until displayColumns) { |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2376 var content = model.getRowAndColumn(position, i) |
2565
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
2377 |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
2378 // Image |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
2379 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
|
2380 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
|
2381 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
|
2382 LinearLayout.LayoutParams.WRAP_CONTENT) |
2834
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2383 if(contMode == 2) |
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2384 params.gravity = Gravity.LEFT |
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2385 else |
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2386 params.gravity = Gravity.CENTER |
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
|
2387 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
|
2388 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
|
2389 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
|
2390 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
|
2391 } |
2841
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2392 rowView.stack.addView(imageview) |
2565
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
2393 } else { |
2835
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2394 // Everything else is displayed as text |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2395 var textview: TextView? = null |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2396 |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2397 // Special case for DW_CONTAINER_MODE_MULTI |
2841
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2398 if(contMode == 2) { |
2835
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2399 // textview will be a text button instead |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2400 textview = Button(context) |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2401 } else { |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2402 textview = TextView(context) |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2403 } |
2834
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2404 var hsize = LinearLayout.LayoutParams.WRAP_CONTENT |
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2405 if(contMode == 0) |
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2406 hsize = LinearLayout.LayoutParams.MATCH_PARENT |
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2407 val params = LinearLayout.LayoutParams(hsize, LinearLayout.LayoutParams.WRAP_CONTENT) |
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2408 if(contMode == 2) |
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2409 params.gravity = Gravity.LEFT |
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2410 else |
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2411 params.gravity = Gravity.CENTER |
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2412 // Multi-line (vertical) mode does not require horizontal margins |
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2413 if(contMode != 2) |
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2414 params.setMargins(5, 0, 5, 0) |
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
|
2415 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
|
2416 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
|
2417 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
|
2418 textview.text = content |
2834
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2419 } else if(content is Long || content is Int) { |
2565
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
2420 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
|
2421 } |
2835
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2422 textview.setOnClickListener { |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2423 var columnClicked: Int = i |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2424 if(isFilesystem) { |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2425 columnClicked = i - 1 |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2426 } |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2427 eventHandlerInt(parent, DWEvent.COLUMN_CLICK, columnClicked, 0, 0, 0) |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2428 } |
2841
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2429 rowView.stack.addView(textview) |
2561
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
2430 } |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2431 } |
2561
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
2432 } else { |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
2433 // Otherwise we just need to update the existing layout |
2841
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2434 for(i in extraColumns until displayColumns) { |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2435 var content = model.getRowAndColumn(position, i) |
2565
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
2436 |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
2437 // Image |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
2438 if((model.getColumnType(i) and 1) != 0) { |
2841
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2439 val imageview = rowView.stack.getChildAt(i - extraColumns) |
2565
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
2440 |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
2441 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
|
2442 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
|
2443 } |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
2444 } else { |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
2445 // Text |
2841
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2446 val textview = rowView.stack.getChildAt(i - extraColumns) |
2565
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
2447 |
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
2448 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
|
2449 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
|
2450 textview.text = content |
2834
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2451 } else if (content is Long || content is Int) { |
2565
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
2452 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
|
2453 } |
2677
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
2454 if(foreColor != null) { |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
2455 textview.setTextColor(foreColor!!) |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
2456 } |
2565
5463801a888f
Android: Attempt to rewrite container layout code in a more generic manner.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2564
diff
changeset
|
2457 } |
2561
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
2458 } |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2459 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2460 } |
2841
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2461 |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2462 var content = model.getRowAndColumn(position, 0) |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2463 |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2464 // Setup the built-in Image and Text based on if we are fileystem mode or not |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2465 if(isFilesystem) { |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2466 if(content is Drawable) { |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2467 rowView.imageview.setImageDrawable(content) |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2468 } |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2469 content = model.getRowAndColumn(position, 1) |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2470 if (content is String) { |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2471 rowView.text.text = content |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2472 } else if(content is Long || content is Int) { |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2473 rowView.text.text = content.toString() |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2474 } |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2475 } else { |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2476 if(content is Drawable) { |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2477 rowView.imageview.setImageDrawable(content) |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2478 } else if (content is String) { |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2479 rowView.text.text = content |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2480 } else if(content is Long || content is Int) { |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2481 rowView.text.text = content.toString() |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2482 } |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2483 } |
3e88b961f801
Android: Rewrite DWContainerRow using RelativeLayout and a LinearLayout stack.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2835
diff
changeset
|
2484 |
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
|
2485 // 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
|
2486 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
|
2487 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
|
2488 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
|
2489 } 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
|
2490 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
|
2491 } |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2492 } 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
|
2493 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
|
2494 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
|
2495 } 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
|
2496 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
|
2497 } |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
2498 } |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2499 return rowView |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2500 } |
2835
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2501 external fun eventHandlerInt( |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2502 obj1: View, |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2503 message: Int, |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2504 inta: Int, |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2505 intb: Int, |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2506 intc: Int, |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2507 intd: Int |
1f0017a07771
Android: Implement DW_SIGNAL_COLUMN_CLICK for containers in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2834
diff
changeset
|
2508 ) |
2555
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2509 } |
d7d163d70763
Android: Initial implementations of DWContainerModel and DWContainerAdapter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2554
diff
changeset
|
2510 |
2702
4f12dc8e8f18
Android: Implement dw_mle_set_auto_complete() in the same way as iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2701
diff
changeset
|
2511 private class DWMLE(c: Context): AppCompatEditText(c) { |
2701
9df2c11f020f
Android: Fix dw_mle_set_word_wrap() and dw_mle_set_cursor().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2694
diff
changeset
|
2512 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
|
2513 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
|
2514 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
|
2515 } else { |
9df2c11f020f
Android: Fix dw_mle_set_word_wrap() and dw_mle_set_cursor().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2694
diff
changeset
|
2516 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
|
2517 } |
9df2c11f020f
Android: Fix dw_mle_set_word_wrap() and dw_mle_set_cursor().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2694
diff
changeset
|
2518 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
|
2519 } |
9df2c11f020f
Android: Fix dw_mle_set_word_wrap() and dw_mle_set_cursor().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2694
diff
changeset
|
2520 } |
9df2c11f020f
Android: Fix dw_mle_set_word_wrap() and dw_mle_set_cursor().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2694
diff
changeset
|
2521 |
2756
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2522 fun getPlatformSelectionColor(context: Context): Int { |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2523 val bitmap = BitmapFactory.decodeResource(context.resources, R.drawable.list_selector_background) |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2524 var redBucket: Float = 0f |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2525 var greenBucket: Float = 0f |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2526 var blueBucket: Float = 0f |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2527 var pixelCount: Float = 0f |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2528 |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2529 if(bitmap != null) { |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2530 for (y in 0 until bitmap.height) { |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2531 for (x in 0 until bitmap.width) { |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2532 val c = bitmap.getPixel(x, y) |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2533 pixelCount++ |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2534 redBucket += Color.red(c) |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2535 greenBucket += Color.green(c) |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2536 blueBucket += Color.blue(c) |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2537 } |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2538 } |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2539 |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2540 return Color.rgb( |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2541 (redBucket / pixelCount).toInt(), |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2542 (greenBucket / pixelCount).toInt(), |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2543 (blueBucket / pixelCount).toInt() |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2544 ) |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2545 } |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2546 return Color.GRAY |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2547 } |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2548 |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
2549 class DWindows : AppCompatActivity() { |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2550 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
|
2551 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
|
2552 var threadCond = threadLock.newCondition() |
2522
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
2553 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
|
2554 var darkMode: Int = -1 |
2834
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2555 var contMode: Int = 0 |
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
|
2556 var lastClickView: View? = null |
2756
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2557 var colorSelection: Int = Color.DKGRAY |
2690
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
2558 private var appID: String? = null |
2531
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
2559 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
|
2560 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
|
2561 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
|
2562 private var fileLock = ReentrantLock() |
2715
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
2563 private var fileCond = fileLock.newCondition() |
2722
cacde852e2db
Android: Add dialog dismiss and color change handlers to the color chooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2720
diff
changeset
|
2564 private var colorLock = ReentrantLock() |
cacde852e2db
Android: Add dialog dismiss and color change handlers to the color chooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2720
diff
changeset
|
2565 private var colorCond = colorLock.newCondition() |
cacde852e2db
Android: Add dialog dismiss and color change handlers to the color chooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2720
diff
changeset
|
2566 private var colorChosen: Int = 0 |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2567 // 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
|
2568 private var windowTitles = mutableListOf<String?>() |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2569 private var windowMenuBars = mutableListOf<DWMenu?>() |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2570 private var windowStyles = mutableListOf<Int>() |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2571 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
|
2572 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2573 // 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
|
2574 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
|
2575 { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2576 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
|
2577 runnable.run() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2578 } else { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2579 threadLock.lock() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2580 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
|
2581 threadLock.lock() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2582 runnable.run() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2583 threadCond.signal() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2584 threadLock.unlock() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2585 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2586 runOnUiThread(ourRunnable) |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2587 threadCond.await() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2588 threadLock.unlock() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2589 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2590 } |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
2591 |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2592 // 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
|
2593 // 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
|
2594 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
|
2595 val length = filename.length |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2596 |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2597 for (ext in DWImageExts) { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2598 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
|
2599 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
|
2600 try { |
3a14d7fd4b99
Android: Catch NumberFormatException in isDWResource().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2658
diff
changeset
|
2601 if (filebody.toInt() > 0) { |
3a14d7fd4b99
Android: Catch NumberFormatException in isDWResource().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2658
diff
changeset
|
2602 return true |
3a14d7fd4b99
Android: Catch NumberFormatException in isDWResource().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2658
diff
changeset
|
2603 } |
3a14d7fd4b99
Android: Catch NumberFormatException in isDWResource().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2658
diff
changeset
|
2604 } catch(e: NumberFormatException) { |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2605 } |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2606 } |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2607 } |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2608 return false |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2609 } |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2610 |
2659
3a14d7fd4b99
Android: Catch NumberFormatException in isDWResource().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2658
diff
changeset
|
2611 // 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
|
2612 private fun extractAssets() { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2613 var zipFile: ZipFile? = null |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2614 val targetDir = cacheDir |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2615 |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2616 try { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2617 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
|
2618 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
|
2619 while (e.hasMoreElements()) { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2620 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
|
2621 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
|
2622 isDWResource(entry.name)) { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2623 continue |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2624 } |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2625 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
|
2626 targetFile.parentFile!!.mkdirs() |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2627 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
|
2628 var ais: BufferedInputStream? = null |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2629 var aos: FileOutputStream? = null |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2630 try { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2631 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
|
2632 aos = FileOutputStream(targetFile) |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2633 ais.read(tempBuffer) |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2634 aos.write(tempBuffer) |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2635 } catch (e: IOException) { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2636 } finally { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2637 ais?.close() |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2638 aos?.close() |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2639 } |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2640 } |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2641 } catch (e: IOException) { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2642 } finally { |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2643 zipFile?.close() |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2644 } |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2645 } |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2646 |
2498
4ae2b3b77f25
Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2497
diff
changeset
|
2647 // 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
|
2648 // 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
|
2649 // 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
|
2650 // 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
|
2651 // 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
|
2652 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
|
2653 super.onCreate(savedInstanceState) |
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2654 |
2480
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
2655 // Turn on rotation |
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
2656 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
|
2657 |
2498
4ae2b3b77f25
Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2497
diff
changeset
|
2658 // 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
|
2659 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
|
2660 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
|
2661 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
|
2662 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
|
2663 val c = cacheDir.path |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2664 |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2665 // 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
|
2666 // 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
|
2667 // other Dynamic Windows platforms |
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
2668 extractAssets() |
2474
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
2669 |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2670 // 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
|
2671 windowLayout = ViewPager2(this) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2672 windowLayout!!.id = View.generateViewId() |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2673 windowLayout!!.adapter = DWTabViewPagerAdapter() |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2674 windowLayout!!.isUserInputEnabled = false |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2675 windowLayout!!.layoutParams = |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2676 ViewGroup.LayoutParams( |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2677 ViewGroup.LayoutParams.MATCH_PARENT, |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2678 ViewGroup.LayoutParams.MATCH_PARENT |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2679 ) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2680 |
2756
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2681 colorSelection = getPlatformSelectionColor(this) |
4f09bf72b391
Android: Attempt to get the selection background color from the theme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2755
diff
changeset
|
2682 |
2498
4ae2b3b77f25
Android: Get the notebook control functional. Disable recylcing of the views.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2497
diff
changeset
|
2683 // 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
|
2684 // 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
|
2685 dwindowsInit(s, c, this.getPackageName()) |
2496
3bf2f08fdc45
Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2495
diff
changeset
|
2686 } |
3bf2f08fdc45
Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2495
diff
changeset
|
2687 |
3bf2f08fdc45
Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2495
diff
changeset
|
2688 override fun onConfigurationChanged(newConfig: Configuration) { |
3bf2f08fdc45
Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2495
diff
changeset
|
2689 super.onConfigurationChanged(newConfig) |
3bf2f08fdc45
Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2495
diff
changeset
|
2690 |
2551
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
2691 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
|
2692 when (currentNightMode) { |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
2693 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
|
2694 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
|
2695 } |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
2696 |
2499
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
2697 // 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
|
2698 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
|
2699 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
|
2700 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
|
2701 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
|
2702 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
|
2703 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
|
2704 |
17c34bdaec6c
Android: Put in some list bounds safety checks... them getting hit however...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2684
diff
changeset
|
2705 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
|
2706 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
|
2707 |
17c34bdaec6c
Android: Put in some list bounds safety checks... them getting hit however...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2684
diff
changeset
|
2708 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
|
2709 } |
2496
3bf2f08fdc45
Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2495
diff
changeset
|
2710 } |
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
2711 } |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
2712 |
2788
8a4f162810c2
Android: During dw_file_browse() request read/write access to external
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2785
diff
changeset
|
2713 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
|
2714 if(windowLayout != null) { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2715 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
|
2716 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
|
2717 |
17c34bdaec6c
Android: Put in some list bounds safety checks... them getting hit however...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2684
diff
changeset
|
2718 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
|
2719 var menuBar = windowMenuBars[index] |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2720 |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2721 if(menuBar == null) { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2722 menuBar = DWMenu() |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2723 windowMenuBars[index] = menuBar |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2724 } |
2707
a3f6ca621453
Android: Implement dw_mle_set_visible(). Also fix various warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2706
diff
changeset
|
2725 menuBar.menu = menu |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2726 return super.onCreateOptionsMenu(menu) |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2727 } |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2728 } |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2729 return false |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2730 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2731 |
2788
8a4f162810c2
Android: During dw_file_browse() request read/write access to external
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2785
diff
changeset
|
2732 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
|
2733 if(windowLayout != null) { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2734 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
|
2735 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
|
2736 |
17c34bdaec6c
Android: Put in some list bounds safety checks... them getting hit however...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2684
diff
changeset
|
2737 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
|
2738 var menuBar = windowMenuBars[index] |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2739 |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2740 if(menuBar != null) { |
2707
a3f6ca621453
Android: Implement dw_mle_set_visible(). Also fix various warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2706
diff
changeset
|
2741 menuBar.createMenu(menu, true) |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2742 } else { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2743 menuBar = DWMenu() |
2707
a3f6ca621453
Android: Implement dw_mle_set_visible(). Also fix various warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2706
diff
changeset
|
2744 menuBar.createMenu(menu, true) |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2745 windowMenuBars[index] = menuBar |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2746 } |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2747 return super.onPrepareOptionsMenu(menu) |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2748 } |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2749 } |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2750 return false |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2751 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2752 |
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
|
2753 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
|
2754 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
|
2755 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
|
2756 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
|
2757 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
|
2758 |
2670
e3a95940c18f
Android: Implement DW_FCF_CLOSEBUTTON and DW_FCF_TITLEBAR flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2669
diff
changeset
|
2759 // 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
|
2760 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
|
2761 // 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
|
2762 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
|
2763 } |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
2764 } |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
2765 } |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
2766 |
2552
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
2767 // 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
|
2768 // 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
|
2769 |
2551
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
2770 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
|
2771 { |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
2772 return darkMode |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
2773 } |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
2774 |
2834
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2775 fun setContainerMode(mode: Int) |
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2776 { |
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2777 contMode = mode |
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2778 } |
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
2779 |
2694
cee79add3669
Andrdoid: Implement dw_browse() to load a URL in a new Activity.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2692
diff
changeset
|
2780 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
|
2781 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
|
2782 |
cee79add3669
Andrdoid: Implement dw_browse() to load a URL in a new Activity.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2692
diff
changeset
|
2783 waitOnUiThread { |
cee79add3669
Andrdoid: Implement dw_browse() to load a URL in a new Activity.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2692
diff
changeset
|
2784 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
|
2785 try { |
cee79add3669
Andrdoid: Implement dw_browse() to load a URL in a new Activity.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2692
diff
changeset
|
2786 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
|
2787 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
|
2788 } 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
|
2789 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
|
2790 } |
cee79add3669
Andrdoid: Implement dw_browse() to load a URL in a new Activity.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2692
diff
changeset
|
2791 } |
cee79add3669
Andrdoid: Implement dw_browse() to load a URL in a new Activity.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2692
diff
changeset
|
2792 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
|
2793 } |
cee79add3669
Andrdoid: Implement dw_browse() to load a URL in a new Activity.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2692
diff
changeset
|
2794 |
2607
3b9bbd69bb9c
Android: Implement dw_menu_popup() ... still need to implement the context events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2596
diff
changeset
|
2795 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
|
2796 { |
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
|
2797 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
|
2798 |
dbcd9416e9c9
Android: Popup menus on Andoird use an anchor View not the touch location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2613
diff
changeset
|
2799 // 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
|
2800 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
|
2801 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
|
2802 } |
dbcd9416e9c9
Android: Popup menus on Andoird use an anchor View not the touch location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2613
diff
changeset
|
2803 |
2607
3b9bbd69bb9c
Android: Implement dw_menu_popup() ... still need to implement the context events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2596
diff
changeset
|
2804 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
|
2805 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
|
2806 |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2807 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
|
2808 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
|
2809 } |
3b9bbd69bb9c
Android: Implement dw_menu_popup() ... still need to implement the context events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2596
diff
changeset
|
2810 } |
3b9bbd69bb9c
Android: Implement dw_menu_popup() ... still need to implement the context events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2596
diff
changeset
|
2811 |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2812 fun menuBarNew(location: View): DWMenu? |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2813 { |
2666
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2814 var menuBar: DWMenu? = null |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2815 |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2816 if(windowLayout != null) { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2817 waitOnUiThread { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2818 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
|
2819 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
|
2820 |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2821 if (index != -1) { |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2822 menuBar = DWMenu() |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2823 windowMenuBars[index] = menuBar |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2824 } |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2825 } |
4f2d433747e2
Android: Rewrite the menubar code for multi-window support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2665
diff
changeset
|
2826 } |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2827 return menuBar |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2828 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2829 |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2830 fun menuNew(cid: Int): DWMenu |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2831 { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2832 val menu = DWMenu() |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2833 menu.id = cid |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2834 return menu |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2835 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2836 |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2837 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
|
2838 { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2839 val menuitem = DWMenuItem() |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2840 menuitem.id = cid |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2841 menuitem.title = title |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2842 menuitem.check = check != 0 |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2843 if(submenu != null) { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2844 menuitem.submenu = submenu |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2845 } |
2546
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
2846 if((flags and (1 shl 1)) != 0) { |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
2847 menuitem.enabled = false |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
2848 } |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2849 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
|
2850 menuitem.checked = true |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2851 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2852 if(end == 0) { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2853 menu.children.add(0, menuitem) |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2854 } else { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2855 menu.children.add(menuitem) |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2856 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2857 return menuitem |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2858 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
2859 |
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
|
2860 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
|
2861 { |
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
|
2862 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
|
2863 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
|
2864 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
|
2865 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
|
2866 } |
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
|
2867 } |
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
|
2868 |
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
|
2869 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
|
2870 { |
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
|
2871 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
|
2872 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
|
2873 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
|
2874 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
|
2875 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
|
2876 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
|
2877 } |
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
|
2878 } |
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
|
2879 } |
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
|
2880 } |
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
|
2881 |
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
|
2882 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
|
2883 { |
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
|
2884 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
|
2885 if(menuitem.id == cid) { |
2806
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
2886 var changed: Boolean = false |
2546
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
2887 // Handle DW_MIS_ENABLED/DISABLED |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
2888 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
|
2889 var enabled = false |
2546
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
2890 |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
2891 // Handle DW_MIS_ENABLED |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
2892 if ((state and 1) != 0) { |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
2893 enabled = true |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
2894 } |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
2895 menuitem.enabled = enabled |
2806
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
2896 if (menuitem.menuitem != null && menuitem.menuitem!!.isEnabled != enabled) { |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
2897 menuitem.menuitem!!.isEnabled = enabled |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
2898 changed = true |
2546
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
2899 } |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
2900 } |
897d94c20365
Android: Implement disabled menu items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2545
diff
changeset
|
2901 |
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
|
2902 // 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
|
2903 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
|
2904 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
|
2905 |
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
|
2906 // 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
|
2907 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
|
2908 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
|
2909 } |
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
|
2910 menuitem.checked = checked |
2806
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
2911 if (menuitem.menuitem != null && menuitem.menuitem!!.isChecked != checked) { |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
2912 menuitem.menuitem!!.isChecked = checked |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
2913 changed = true |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
2914 } |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
2915 if(changed == true) { |
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
|
2916 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
|
2917 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
|
2918 } |
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
|
2919 } |
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
|
2920 } |
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
|
2921 } |
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
|
2922 } |
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
|
2923 } |
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
|
2924 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
2925 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
|
2926 var window: LinearLayout? = null |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2927 |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2928 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
|
2929 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2930 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
|
2931 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
|
2932 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
2933 setContentView(windowLayout) |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2934 |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2935 window = LinearLayout(this) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2936 window!!.visibility = View.GONE |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2937 window!!.tag = dataArrayMap |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2938 window!!.layoutParams = |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2939 LinearLayout.LayoutParams( |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2940 LinearLayout.LayoutParams.MATCH_PARENT, |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2941 LinearLayout.LayoutParams.MATCH_PARENT |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2942 ) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2943 |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2944 // Update our window list |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2945 adapter.viewList.add(window!!) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2946 windowTitles.add(title) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2947 windowMenuBars.add(null) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2948 windowStyles.add(style) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2949 windowDefault.add(null) |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2950 |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2951 // 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
|
2952 // We can set stuff immediately |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2953 if (adapter.viewList.count() == 1) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2954 this.title = title |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2955 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
|
2956 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
|
2957 supportActionBar?.hide() |
e3a95940c18f
Android: Implement DW_FCF_CLOSEBUTTON and DW_FCF_TITLEBAR flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2669
diff
changeset
|
2958 } |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2959 } |
2691
e13607b87517
Android: Call notifyDataSetChanged() on ViewPager2 adapters to fix some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2690
diff
changeset
|
2960 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
|
2961 } |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
2962 } |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2963 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
|
2964 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
2965 |
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
|
2966 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
|
2967 { |
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
|
2968 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
|
2969 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
|
2970 } |
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
|
2971 } |
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
|
2972 |
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
|
2973 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
|
2974 { |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2975 if(windowLayout != null) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2976 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
|
2977 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
|
2978 |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2979 if (index != -1) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2980 windowDefault[index] = default |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2981 } |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2982 } |
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
|
2983 } |
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
|
2984 |
2790
20d39af27aa4
Android: Add a new function for Android dw_file_open() which will open the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2789
diff
changeset
|
2985 fun windowSetStyle(window: Any, style: Int, mask: Int) |
20d39af27aa4
Android: Add a new function for Android dw_file_open() which will open the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2789
diff
changeset
|
2986 { |
20d39af27aa4
Android: Add a new function for Android dw_file_open() which will open the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2789
diff
changeset
|
2987 // TODO: Need to handle menu items and others |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2988 waitOnUiThread { |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2989 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
|
2990 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
|
2991 |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2992 if (ourmask != 0) { |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
2993 // 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
|
2994 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
|
2995 |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
2996 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
|
2997 } |
2803
708bcef0ce6b
Android: Add support for DW_BS_NOBORDER on bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2799
diff
changeset
|
2998 } else if(window is ImageButton) { |
708bcef0ce6b
Android: Add support for DW_BS_NOBORDER on bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2799
diff
changeset
|
2999 // DW_BS_NOBORDER = 1 |
708bcef0ce6b
Android: Add support for DW_BS_NOBORDER on bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2799
diff
changeset
|
3000 if((mask and 1) == 1) { |
708bcef0ce6b
Android: Add support for DW_BS_NOBORDER on bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2799
diff
changeset
|
3001 val button = window as ImageButton |
708bcef0ce6b
Android: Add support for DW_BS_NOBORDER on bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2799
diff
changeset
|
3002 if((style and 1) == 1) { |
708bcef0ce6b
Android: Add support for DW_BS_NOBORDER on bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2799
diff
changeset
|
3003 button.background = null |
708bcef0ce6b
Android: Add support for DW_BS_NOBORDER on bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2799
diff
changeset
|
3004 } // TODO: Handle turning border back on if possible |
708bcef0ce6b
Android: Add support for DW_BS_NOBORDER on bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2799
diff
changeset
|
3005 } |
2806
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3006 } else if(window is DWMenuItem) { |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3007 var menuitem = window as DWMenuItem |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3008 var changed: Boolean = false |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3009 |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3010 // Handle DW_MIS_ENABLED/DISABLED |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3011 if((mask and (1 or (1 shl 1))) != 0) { |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3012 var enabled = false |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3013 |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3014 // Handle DW_MIS_ENABLED = 1 or DW_MIS_DISABLED = 0 |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3015 if (((mask and 1) != 0 && (style and 1) != 0) || |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3016 ((mask and (1 shl 1) != 0 && (style and (1 shl 1) == 0)))) { |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3017 enabled = true |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3018 } |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3019 menuitem.enabled = enabled |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3020 if(menuitem.menuitem != null && menuitem.menuitem!!.isEnabled != enabled) { |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3021 menuitem.menuitem!!.isEnabled = enabled |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3022 changed = true |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3023 } |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3024 } |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3025 |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3026 // Handle DW_MIS_CHECKED/UNCHECKED |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3027 if((mask and ((1 shl 2) or (1 shl 3))) != 0) { |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3028 var checked = false |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3029 |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3030 // Handle DW_MIS_CHECKED = 1 or DW_MIS_UNCHECKED = 0 |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3031 if (((mask and (1 shl 2)) != 0 && (style and (1 shl 2)) != 0) || |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3032 ((mask and (1 shl 3) != 0 && (style and (1 shl 3) == 0)))) { |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3033 checked = true |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3034 } |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3035 menuitem.checked = checked |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3036 if (menuitem.menuitem != null && menuitem.menuitem!!.isChecked != checked) { |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3037 menuitem.menuitem!!.isChecked = checked |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3038 changed = true |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3039 } |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3040 } |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3041 if(changed == true) { |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3042 runOnUiThread { |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3043 invalidateOptionsMenu() |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3044 } |
d7b6e19e44d2
Android: Add support for menu item handles in dw_window_set_style().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2805
diff
changeset
|
3045 } |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3046 } |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3047 } |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3048 } |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3049 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
3050 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
|
3051 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
|
3052 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
3053 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
3054 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
|
3055 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
|
3056 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
|
3057 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
3058 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
|
3059 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
|
3060 } else { |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
3061 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
|
3062 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
3063 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
3064 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
3065 |
2686
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
3066 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
|
3067 { |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
3068 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
|
3069 |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
3070 waitOnUiThread { |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
3071 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
|
3072 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
|
3073 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
|
3074 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
|
3075 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
|
3076 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
|
3077 |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
3078 // 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
|
3079 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
|
3080 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
|
3081 } |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
3082 } |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
3083 } |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
3084 return retval |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
3085 } |
95f61d3f3d0d
Android: Initial attempt at implmenting dw_window_get_preferred_size().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2685
diff
changeset
|
3086 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
3087 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
|
3088 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
|
3089 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
3090 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
|
3091 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
|
3092 |
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
|
3093 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
|
3094 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
|
3095 } |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
3096 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
3097 return retval |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
3098 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
3099 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
3100 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
|
3101 waitOnUiThread { |
2808
965c3c6ed1ed
Android: Gray out disabled bitmap buttons...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2806
diff
changeset
|
3102 window.isEnabled = state |
965c3c6ed1ed
Android: Gray out disabled bitmap buttons...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2806
diff
changeset
|
3103 if(window is ImageButton) { |
965c3c6ed1ed
Android: Gray out disabled bitmap buttons...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2806
diff
changeset
|
3104 val ib = window as ImageButton |
965c3c6ed1ed
Android: Gray out disabled bitmap buttons...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2806
diff
changeset
|
3105 |
965c3c6ed1ed
Android: Gray out disabled bitmap buttons...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2806
diff
changeset
|
3106 if(ib.drawable != null) { |
965c3c6ed1ed
Android: Gray out disabled bitmap buttons...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2806
diff
changeset
|
3107 if(state) { |
2809
f81e92947f4a
Android: Change syntax of previous commit to avoid deprecations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2808
diff
changeset
|
3108 ib.drawable.colorFilter = null |
2808
965c3c6ed1ed
Android: Gray out disabled bitmap buttons...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2806
diff
changeset
|
3109 } else { |
2809
f81e92947f4a
Android: Change syntax of previous commit to avoid deprecations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2808
diff
changeset
|
3110 ib.drawable.colorFilter = PorterDuffColorFilter(Color.LTGRAY, PorterDuff.Mode.SRC_IN) |
2808
965c3c6ed1ed
Android: Gray out disabled bitmap buttons...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2806
diff
changeset
|
3111 } |
965c3c6ed1ed
Android: Gray out disabled bitmap buttons...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2806
diff
changeset
|
3112 if(ib.background != null) { |
965c3c6ed1ed
Android: Gray out disabled bitmap buttons...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2806
diff
changeset
|
3113 if(state) { |
2809
f81e92947f4a
Android: Change syntax of previous commit to avoid deprecations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2808
diff
changeset
|
3114 ib.background.colorFilter = null |
2808
965c3c6ed1ed
Android: Gray out disabled bitmap buttons...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2806
diff
changeset
|
3115 } else { |
2809
f81e92947f4a
Android: Change syntax of previous commit to avoid deprecations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2808
diff
changeset
|
3116 ib.background.colorFilter = PorterDuffColorFilter(Color.LTGRAY, PorterDuff.Mode.SRC_IN) |
2808
965c3c6ed1ed
Android: Gray out disabled bitmap buttons...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2806
diff
changeset
|
3117 } |
965c3c6ed1ed
Android: Gray out disabled bitmap buttons...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2806
diff
changeset
|
3118 } |
965c3c6ed1ed
Android: Gray out disabled bitmap buttons...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2806
diff
changeset
|
3119 } |
965c3c6ed1ed
Android: Gray out disabled bitmap buttons...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2806
diff
changeset
|
3120 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3121 } |
2475
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
3122 } |
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
3123 |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3124 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
|
3125 { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3126 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
|
3127 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
|
3128 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
|
3129 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
|
3130 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
|
3131 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
|
3132 |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3133 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
|
3134 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
|
3135 } 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
|
3136 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
|
3137 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3138 |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3139 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
|
3140 if (bold && italic) { |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3141 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
|
3142 } else if (bold) { |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3143 style = Typeface.BOLD |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3144 } else if (italic) { |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3145 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
|
3146 } |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3147 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
|
3148 |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3149 return typeface |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3150 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3151 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
|
3152 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3153 |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3154 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
|
3155 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
|
3156 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
|
3157 |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3158 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
|
3159 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
|
3160 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3161 |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3162 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
|
3163 waitOnUiThread { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3164 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
|
3165 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
|
3166 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
|
3167 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
|
3168 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
|
3169 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3170 } 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
|
3171 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
|
3172 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
|
3173 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
|
3174 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
|
3175 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3176 } 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
|
3177 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
|
3178 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
|
3179 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
|
3180 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
|
3181 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3182 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3183 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3184 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3185 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3186 |
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
|
3187 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
|
3188 { |
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
|
3189 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
|
3190 |
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
|
3191 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
|
3192 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
|
3193 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
|
3194 |
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
|
3195 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
|
3196 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
|
3197 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
|
3198 } 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
|
3199 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
|
3200 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
|
3201 } 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
|
3202 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
|
3203 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
|
3204 } |
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
|
3205 |
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
|
3206 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
|
3207 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
|
3208 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
|
3209 |
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
|
3210 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
|
3211 } |
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
|
3212 } |
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
|
3213 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
|
3214 } |
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
|
3215 |
2551
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
3216 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
|
3217 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
|
3218 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
|
3219 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
|
3220 |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
3221 // 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
|
3222 // 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
|
3223 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
|
3224 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
|
3225 } |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3226 |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3227 waitOnUiThread { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3228 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
|
3229 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
|
3230 |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
3231 // 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
|
3232 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
|
3233 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
|
3234 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
|
3235 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
|
3236 } |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
3237 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
|
3238 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
|
3239 } 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
|
3240 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
|
3241 |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
3242 // 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
|
3243 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
|
3244 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
|
3245 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
|
3246 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
|
3247 } |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
3248 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
|
3249 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
|
3250 } 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
|
3251 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
|
3252 |
127779860ac1
Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2550
diff
changeset
|
3253 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
|
3254 } 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
|
3255 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
|
3256 |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
3257 // 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
|
3258 if(fore == 16) { |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
3259 val value = TypedValue() |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
3260 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
|
3261 colorfore = value.data |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
3262 } |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
3263 |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
3264 listbox.colorFore = colorfore |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
3265 listbox.colorBack = colorback |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
3266 |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
3267 listbox.setBackgroundColor(colorback) |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
3268 } 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
|
3269 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
|
3270 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
|
3271 |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
3272 // 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
|
3273 if(fore == 16) { |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
3274 val value = TypedValue() |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
3275 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
|
3276 colorfore = value.data |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
3277 } |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
3278 |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
3279 adapter.foreColor = colorfore |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
3280 adapter.backColor = colorback |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
3281 |
c90b2d7057c8
Android: Implement dw_window_set_color() on Containers and Listboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2676
diff
changeset
|
3282 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
|
3283 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3284 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3285 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
3286 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
3287 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
|
3288 if(windowLayout != null) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3289 waitOnUiThread { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3290 if (window is TextView) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3291 val textview: TextView = window |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3292 textview.text = text |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3293 } else if (window is Button) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3294 val button: Button = window |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3295 button.text = text |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3296 } else if (window is LinearLayout) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3297 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
|
3298 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
|
3299 |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3300 if(index != -1) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3301 windowTitles[index] = text |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3302 if(index == windowLayout!!.currentItem) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3303 this.title = text |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3304 } |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3305 } |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3306 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3307 } |
2489
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
3308 } |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
3309 } |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
3310 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
3311 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
|
3312 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
|
3313 |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3314 if(windowLayout != null) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3315 waitOnUiThread { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3316 if (window is TextView) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3317 val textview: TextView = window |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3318 text = textview.text.toString() |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3319 } else if (window is Button) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3320 val button: Button = window |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3321 text = button.text.toString() |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3322 } else if (window is LinearLayout) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3323 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
|
3324 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
|
3325 |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3326 if(index != -1) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3327 text = windowTitles[index] |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3328 } |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3329 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3330 } |
2489
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
3331 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3332 return text |
2489
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
3333 } |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
3334 |
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
|
3335 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
|
3336 { |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
3337 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
|
3338 |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
3339 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
|
3340 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
|
3341 |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
3342 // 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
|
3343 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
|
3344 // 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
|
3345 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
|
3346 // 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
|
3347 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
|
3348 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
|
3349 } |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
3350 // 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
|
3351 // So using RecyclerView.scrollToPosition() also |
2ad924c6493d
Android: Still need to call setCurrentItem() on ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2668
diff
changeset
|
3352 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
|
3353 |
2670
e3a95940c18f
Android: Implement DW_FCF_CLOSEBUTTON and DW_FCF_TITLEBAR flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2669
diff
changeset
|
3354 // 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
|
3355 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
|
3356 supportActionBar?.show() |
e3a95940c18f
Android: Implement DW_FCF_CLOSEBUTTON and DW_FCF_TITLEBAR flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2669
diff
changeset
|
3357 } else { |
e3a95940c18f
Android: Implement DW_FCF_CLOSEBUTTON and DW_FCF_TITLEBAR flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2669
diff
changeset
|
3358 supportActionBar?.hide() |
e3a95940c18f
Android: Implement DW_FCF_CLOSEBUTTON and DW_FCF_TITLEBAR flags.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2669
diff
changeset
|
3359 } |
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
|
3360 // 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
|
3361 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
|
3362 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
|
3363 } |
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
|
3364 // 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
|
3365 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
|
3366 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
|
3367 } 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
|
3368 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
|
3369 } |
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
|
3370 // 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
|
3371 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
|
3372 } |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
3373 } |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
3374 } |
2ae70678c845
Android: Use a RecyclerView method to change the ViewPager2 page since the ViewPager2
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2666
diff
changeset
|
3375 |
2503
1c2a79313b04
Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2502
diff
changeset
|
3376 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
|
3377 { |
2665
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3378 if(windowLayout != null) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3379 waitOnUiThread { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3380 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
|
3381 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
|
3382 |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3383 if(state == 0) { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3384 window.visibility = View.GONE |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3385 } else { |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3386 window.visibility = View.VISIBLE |
aca4b56f50dd
Android: Attempt at multi-window support using ViewPager2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2659
diff
changeset
|
3387 } |
2691
e13607b87517
Android: Call notifyDataSetChanged() on ViewPager2 adapters to fix some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2690
diff
changeset
|
3388 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
|
3389 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
|
3390 } |
1c2a79313b04
Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2502
diff
changeset
|
3391 } |
1c2a79313b04
Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2502
diff
changeset
|
3392 } |
1c2a79313b04
Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2502
diff
changeset
|
3393 |
2796
0c534743b7a9
Android: Allow passing a menu window handle to dw_window_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2795
diff
changeset
|
3394 fun windowDestroy(window: Any): Int { |
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
|
3395 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
|
3396 |
2796
0c534743b7a9
Android: Allow passing a menu window handle to dw_window_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2795
diff
changeset
|
3397 if(window is DWMenu) { |
0c534743b7a9
Android: Allow passing a menu window handle to dw_window_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2795
diff
changeset
|
3398 menuDestroy(window as DWMenu) |
0c534743b7a9
Android: Allow passing a menu window handle to dw_window_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2795
diff
changeset
|
3399 retval = 0 // DW_ERROR_NONE |
0c534743b7a9
Android: Allow passing a menu window handle to dw_window_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2795
diff
changeset
|
3400 } else if(windowLayout != null && window is View) { |
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
|
3401 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
|
3402 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
|
3403 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
|
3404 |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
3405 // 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
|
3406 // 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
|
3407 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
|
3408 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
|
3409 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
|
3410 |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
3411 // 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
|
3412 // 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
|
3413 // 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
|
3414 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
|
3415 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
|
3416 } |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
3417 // 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
|
3418 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
|
3419 |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
3420 // 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
|
3421 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
|
3422 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
|
3423 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
|
3424 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
|
3425 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
|
3426 |
2691
e13607b87517
Android: Call notifyDataSetChanged() on ViewPager2 adapters to fix some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2690
diff
changeset
|
3427 adapter.notifyDataSetChanged() |
e13607b87517
Android: Call notifyDataSetChanged() on ViewPager2 adapters to fix some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2690
diff
changeset
|
3428 |
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
|
3429 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
|
3430 } 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
|
3431 // 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
|
3432 // 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
|
3433 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
|
3434 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
|
3435 |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
3436 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
|
3437 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
|
3438 } |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
3439 } |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
3440 } |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
3441 } |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
3442 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
|
3443 } |
917f2d1f9cae
Android: Implement dw_window_destroy() and try to add a back button to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2667
diff
changeset
|
3444 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
3445 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
|
3446 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
|
3447 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
|
3448 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
3449 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
|
3450 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
|
3451 } |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
3452 return "" |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
3453 } |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
3454 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
3455 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
|
3456 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
|
3457 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
|
3458 |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
3459 cm.setPrimaryClip(clipdata) |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
3460 } |
6c01b0132813
Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2488
diff
changeset
|
3461 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3462 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
|
3463 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
|
3464 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3465 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
|
3466 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
|
3467 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3468 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
|
3469 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
|
3470 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
|
3471 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
|
3472 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
|
3473 ) |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3474 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
|
3475 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
|
3476 } else { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3477 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
|
3478 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3479 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
|
3480 } |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
3481 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
|
3482 } |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
3483 |
2689
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
3484 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
|
3485 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
|
3486 waitOnUiThread { |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
3487 box = RadioGroup(this) |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
3488 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
|
3489 |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
3490 box!!.tag = dataArrayMap |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
3491 box!!.layoutParams = |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
3492 LinearLayout.LayoutParams( |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
3493 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
|
3494 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
|
3495 ) |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
3496 if (type > 0) { |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
3497 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
|
3498 } else { |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
3499 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
|
3500 } |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
3501 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
|
3502 } |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
3503 return box |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
3504 } |
7127de139acf
Android: Implement groupbox using RadioGroup... still missing the title and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2688
diff
changeset
|
3505 |
2706
4e9eba7f7226
Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2703
diff
changeset
|
3506 fun scrollBoxNew(type: Int, pad: Int): ScrollView? { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3507 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
|
3508 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3509 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3510 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
|
3511 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
|
3512 val dataArrayMap = SimpleArrayMap<String, Long>() |
2500
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
3513 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3514 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
|
3515 box.layoutParams = |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3516 LinearLayout.LayoutParams( |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3517 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
|
3518 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
|
3519 ) |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3520 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
|
3521 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
|
3522 } else { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3523 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
|
3524 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3525 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
|
3526 // 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
|
3527 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
|
3528 scrollBox!!.addView(box) |
2500
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
3529 } |
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
3530 return scrollBox |
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
3531 } |
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
3532 |
2706
4e9eba7f7226
Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2703
diff
changeset
|
3533 fun scrollBoxGetPos(scrollBox: ScrollView, orient: Int): Int { |
4e9eba7f7226
Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2703
diff
changeset
|
3534 var retval: Int = -1 |
4e9eba7f7226
Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2703
diff
changeset
|
3535 |
4e9eba7f7226
Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2703
diff
changeset
|
3536 waitOnUiThread { |
4e9eba7f7226
Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2703
diff
changeset
|
3537 // DW_VERT 1 |
4e9eba7f7226
Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2703
diff
changeset
|
3538 if(orient == 1) { |
4e9eba7f7226
Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2703
diff
changeset
|
3539 retval = scrollBox.scrollY |
4e9eba7f7226
Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2703
diff
changeset
|
3540 } else { |
4e9eba7f7226
Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2703
diff
changeset
|
3541 retval = scrollBox.scrollX |
4e9eba7f7226
Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2703
diff
changeset
|
3542 } |
4e9eba7f7226
Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2703
diff
changeset
|
3543 } |
4e9eba7f7226
Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2703
diff
changeset
|
3544 return retval |
4e9eba7f7226
Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2703
diff
changeset
|
3545 } |
4e9eba7f7226
Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2703
diff
changeset
|
3546 |
4e9eba7f7226
Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2703
diff
changeset
|
3547 fun scrollBoxGetRange(scrollBox: ScrollView, orient: Int): Int { |
4e9eba7f7226
Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2703
diff
changeset
|
3548 var retval: Int = -1 |
4e9eba7f7226
Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2703
diff
changeset
|
3549 |
4e9eba7f7226
Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2703
diff
changeset
|
3550 waitOnUiThread { |
4e9eba7f7226
Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2703
diff
changeset
|
3551 // DW_VERT 1 |
4e9eba7f7226
Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2703
diff
changeset
|
3552 if(orient == 1) { |
4e9eba7f7226
Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2703
diff
changeset
|
3553 retval = scrollBox.getChildAt(0).height |
4e9eba7f7226
Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2703
diff
changeset
|
3554 } else { |
4e9eba7f7226
Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2703
diff
changeset
|
3555 retval = scrollBox.getChildAt(0).width |
4e9eba7f7226
Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2703
diff
changeset
|
3556 } |
4e9eba7f7226
Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2703
diff
changeset
|
3557 } |
4e9eba7f7226
Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2703
diff
changeset
|
3558 return retval |
4e9eba7f7226
Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2703
diff
changeset
|
3559 } |
4e9eba7f7226
Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2703
diff
changeset
|
3560 |
2683
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3561 // 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
|
3562 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
|
3563 { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3564 val parent = box.parent |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3565 |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3566 if(parent is LinearLayout) { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3567 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
|
3568 |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3569 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
|
3570 if(params.height == 0) { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3571 box.measure(0, 0) |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3572 val calch = box.measuredHeight |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3573 |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3574 if(calch > 0) { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3575 params.weight = calch.toFloat() |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3576 } |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3577 } |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3578 } else { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3579 if(params.width == 0) { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3580 box.measure(0, 0) |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3581 val calcw = box.measuredWidth |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3582 |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3583 if(calcw > 0) { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3584 params.weight = calcw.toFloat() |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3585 } |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3586 } |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3587 } |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3588 } |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3589 } |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3590 |
2495
5664c91d03fb
Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2494
diff
changeset
|
3591 fun boxPack( |
2500
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
3592 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
|
3593 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
|
3594 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
|
3595 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
|
3596 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
|
3597 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
|
3598 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
|
3599 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
|
3600 ) { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3601 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3602 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
|
3603 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
|
3604 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
|
3605 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
|
3606 |
a7868380098f
Android: LinearLayout does not allow null views, if null, create a Placeholder view.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2670
diff
changeset
|
3607 // 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
|
3608 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
|
3609 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
|
3610 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
|
3611 } |
2475
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
3612 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3613 // 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
|
3614 // 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
|
3615 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
|
3616 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
|
3617 } 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
|
3618 val sv: ScrollView = boxview |
2500
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
3619 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3620 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
|
3621 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
|
3622 } |
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
3623 } |
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
3624 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3625 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
|
3626 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
|
3627 |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
3628 // 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
|
3629 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
|
3630 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
|
3631 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
|
3632 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
|
3633 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
|
3634 } |
2683
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3635 if (vsize != 0) { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3636 val calch = item.measuredHeight |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3637 |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3638 if(calch > 0) { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3639 weight = calch.toFloat() |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3640 } else { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3641 weight = 1F |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3642 } |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3643 h = 0 |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3644 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3645 } else { |
2552
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
3646 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
|
3647 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
|
3648 } |
2683
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3649 if (hsize != 0) { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3650 val calcw = item.measuredWidth |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3651 |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3652 if(calcw > 0) { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3653 weight = calcw.toFloat() |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3654 } else { |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3655 weight = 1F |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3656 } |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3657 w = 0 |
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3658 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3659 } |
2552
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
3660 // 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
|
3661 } else { |
2552
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
3662 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
|
3663 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
|
3664 } |
2553
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
3665 if(hsize == 0) { |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
3666 if (width > 0) { |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
3667 w = width |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
3668 } |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
3669 } 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
|
3670 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
|
3671 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
|
3672 } 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
|
3673 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
|
3674 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
|
3675 } 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
|
3676 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
|
3677 |
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
|
3678 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
|
3679 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
|
3680 } |
2553
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
3681 } |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
3682 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3683 } |
2553
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
3684 if(vsize == 0) { |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
3685 if (height > 0) { |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
3686 h = height |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
3687 } |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
3688 } 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
|
3689 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
|
3690 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
|
3691 } 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
|
3692 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
|
3693 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
|
3694 } 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
|
3695 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
|
3696 |
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
|
3697 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
|
3698 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
|
3699 } |
2553
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
3700 } |
2b4f2929408e
Android: Fix issue with specifying static sizes... still some issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2552
diff
changeset
|
3701 } |
2552
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
3702 } |
2500
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
3703 } |
2552
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
3704 |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3705 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
|
3706 |
2552
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
3707 // 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
|
3708 // 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
|
3709 if (box.orientation == LinearLayout.VERTICAL) { |
2681
c1482518b643
Android: Fix weight based layout problems.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2677
diff
changeset
|
3710 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
|
3711 params.weight = weight |
2681
c1482518b643
Android: Fix weight based layout problems.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2677
diff
changeset
|
3712 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
|
3713 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3714 } else { |
2681
c1482518b643
Android: Fix weight based layout problems.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2677
diff
changeset
|
3715 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
|
3716 params.weight = weight |
2681
c1482518b643
Android: Fix weight based layout problems.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2677
diff
changeset
|
3717 params.width = 0 |
2500
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
3718 } |
2480
878d36588aaa
Android: Enable app rotation and fix some issues with layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2479
diff
changeset
|
3719 } |
2552
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
3720 // 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
|
3721 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
|
3722 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
|
3723 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
|
3724 } 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
|
3725 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
|
3726 } 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
|
3727 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
|
3728 } |
303f544d14fa
Android: Refactor boxPack() to try to fix non-expandable items expanding.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2551
diff
changeset
|
3729 // 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
|
3730 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
|
3731 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
|
3732 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3733 item.layoutParams = params |
2805
ebe139dc16dd
Android: Interface Builder passes index 65535 to make sure we are packing to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2803
diff
changeset
|
3734 // If we are out of bounds, pass -1 to add to the end |
ebe139dc16dd
Android: Interface Builder passes index 65535 to make sure we are packing to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2803
diff
changeset
|
3735 if(index >= box.childCount) { |
ebe139dc16dd
Android: Interface Builder passes index 65535 to make sure we are packing to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2803
diff
changeset
|
3736 box.addView(item, -1) |
ebe139dc16dd
Android: Interface Builder passes index 65535 to make sure we are packing to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2803
diff
changeset
|
3737 } else { |
ebe139dc16dd
Android: Interface Builder passes index 65535 to make sure we are packing to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2803
diff
changeset
|
3738 box.addView(item, index) |
ebe139dc16dd
Android: Interface Builder passes index 65535 to make sure we are packing to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2803
diff
changeset
|
3739 } |
2683
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3740 boxUpdate(box) |
2500
ac0b7e579229
Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2499
diff
changeset
|
3741 } |
2478
b0230e378667
Android: Improvements to boxPack to handle more parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2477
diff
changeset
|
3742 } |
2475
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
3743 } |
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
3744 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
3745 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
|
3746 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3747 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
|
3748 box.removeView(item) |
2683
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3749 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
|
3750 } |
2477
3fbf8783122d
Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2476
diff
changeset
|
3751 } |
3fbf8783122d
Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2476
diff
changeset
|
3752 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
3753 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
|
3754 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
|
3755 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3756 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3757 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
|
3758 box.removeView(item) |
2683
e7885fd45f7b
Android: Apply weights to boxes as well as items.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2682
diff
changeset
|
3759 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
|
3760 } |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
3761 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
|
3762 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
3763 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3764 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
|
3765 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
|
3766 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3767 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
|
3768 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
|
3769 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3770 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
|
3771 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
|
3772 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
|
3773 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
|
3774 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
|
3775 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
|
3776 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
|
3777 } |
2482
4888503c3e3e
Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2481
diff
changeset
|
3778 } |
2476
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
3779 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
|
3780 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
3781 |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3782 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
|
3783 var button: ImageButton? = null |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3784 waitOnUiThread { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3785 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
|
3786 val dataArrayMap = SimpleArrayMap<String, Long>() |
2653
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
3787 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
|
3788 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3789 button!!.tag = dataArrayMap |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3790 button!!.id = resid |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3791 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
|
3792 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
|
3793 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
|
3794 } |
2653
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
3795 |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
3796 if(resid > 0 && resid < 65536) { |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
3797 filename = resid.toString() |
2690
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
3798 } else { |
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
3799 button!!.setImageResource(resid) |
2653
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
3800 } |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
3801 |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
3802 if(filename != null) { |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
3803 for (ext in DWImageExts) { |
2653
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
3804 // 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
|
3805 try { |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
3806 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
|
3807 val b = BitmapFactory.decodeStream(f) |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
3808 |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
3809 if (b != null) { |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
3810 button!!.setImageBitmap(b) |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
3811 break |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
3812 } |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
3813 } catch (e: IOException) { |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
3814 } |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
3815 } |
297456a381e4
Android: Similar resource change for bitmap buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2652
diff
changeset
|
3816 } |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3817 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3818 return button |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3819 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3820 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3821 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
|
3822 var button: ImageButton? = null |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3823 waitOnUiThread { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3824 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
|
3825 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
|
3826 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3827 button!!.tag = dataArrayMap |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3828 button!!.id = cid |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3829 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
|
3830 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
|
3831 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
|
3832 } |
2564
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3833 |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
3834 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
|
3835 // 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
|
3836 try { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3837 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
|
3838 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
|
3839 |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3840 if(b != null) { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3841 button!!.setImageBitmap(b) |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3842 break |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3843 } |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3844 } catch (e: IOException) { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
3845 } |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3846 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3847 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3848 return button |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3849 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3850 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3851 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
|
3852 var button: ImageButton? = null |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3853 waitOnUiThread { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3854 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
|
3855 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
|
3856 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
|
3857 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3858 button!!.tag = dataArrayMap |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3859 button!!.id = cid |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3860 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
|
3861 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
|
3862 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
|
3863 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3864 button!!.setImageBitmap(b) |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3865 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3866 return button |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3867 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
3868 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3869 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
|
3870 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
|
3871 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3872 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3873 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
|
3874 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
|
3875 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3876 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
|
3877 entryfield!!.id = cid |
2554
4c75fb6089a9
Android: Need to set isSingleLine for entryfields.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2553
diff
changeset
|
3878 entryfield!!.isSingleLine = true |
2702
4f12dc8e8f18
Android: Implement dw_mle_set_auto_complete() in the same way as iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2701
diff
changeset
|
3879 entryfield!!.inputType = (InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3880 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
|
3881 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
|
3882 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3883 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
|
3884 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
3885 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
|
3886 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
3887 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
3888 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
|
3889 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3890 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
|
3891 } |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
3892 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
3893 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3894 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
|
3895 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
|
3896 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3897 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3898 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
|
3899 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
|
3900 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3901 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
|
3902 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
|
3903 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
|
3904 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
|
3905 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
|
3906 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
|
3907 } |
2482
4888503c3e3e
Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2481
diff
changeset
|
3908 } |
2476
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
3909 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
|
3910 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
3911 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3912 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
|
3913 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
|
3914 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3915 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3916 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
|
3917 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3918 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
|
3919 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
|
3920 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
|
3921 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
|
3922 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
|
3923 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
|
3924 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
|
3925 } |
2482
4888503c3e3e
Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2481
diff
changeset
|
3926 } |
2476
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
3927 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
|
3928 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
3929 |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
3930 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
|
3931 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3932 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3933 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
|
3934 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
|
3935 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
|
3936 } 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
|
3937 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
|
3938 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
|
3939 } |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
3940 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
3941 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
3942 |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
3943 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
|
3944 { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
3945 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
|
3946 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3947 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3948 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
|
3949 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
|
3950 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
|
3951 } 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
|
3952 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
|
3953 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
|
3954 } |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
3955 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3956 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
|
3957 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
3958 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3959 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
|
3960 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
|
3961 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3962 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3963 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
|
3964 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3965 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
|
3966 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
|
3967 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
|
3968 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
|
3969 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
|
3970 val border = GradientDrawable() |
2490
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
3971 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
3972 // 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
|
3973 // 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
|
3974 // 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
|
3975 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
|
3976 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
|
3977 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
|
3978 } |
2490
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
3979 } |
2476
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
3980 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
|
3981 } |
20c9e83cba2a
Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2475
diff
changeset
|
3982 |
2510
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
3983 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
|
3984 { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
3985 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
|
3986 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
3987 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
3988 val dataArrayMap = SimpleArrayMap<String, Long>() |
2702
4f12dc8e8f18
Android: Implement dw_mle_set_auto_complete() in the same way as iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2701
diff
changeset
|
3989 val inputType = (InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE) |
2510
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
3990 |
2701
9df2c11f020f
Android: Fix dw_mle_set_word_wrap() and dw_mle_set_cursor().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2694
diff
changeset
|
3991 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
|
3992 mle!!.tag = dataArrayMap |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
3993 mle!!.id = cid |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
3994 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
|
3995 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
|
3996 mle!!.imeOptions = EditorInfo.IME_FLAG_NO_ENTER_ACTION |
2702
4f12dc8e8f18
Android: Implement dw_mle_set_auto_complete() in the same way as iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2701
diff
changeset
|
3997 mle!!.inputType = (inputType or InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) |
2510
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
3998 mle!!.isVerticalScrollBarEnabled = true |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
3999 mle!!.scrollBarStyle = View.SCROLLBARS_INSIDE_INSET |
2703
321e2cf1282a
Android: Via testing, MLE is set to word wrap by default on most platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2702
diff
changeset
|
4000 mle!!.setHorizontallyScrolling(false) |
321e2cf1282a
Android: Via testing, MLE is set to word wrap by default on most platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2702
diff
changeset
|
4001 mle!!.isHorizontalScrollBarEnabled = false |
2581
9dea42f27b0a
Android: MLE should have TOP/LEFT gravity.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2580
diff
changeset
|
4002 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
|
4003 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4004 return mle |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4005 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4006 |
2707
a3f6ca621453
Android: Implement dw_mle_set_visible(). Also fix various warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2706
diff
changeset
|
4007 fun mleSetVisible(mle: EditText, line: Int) |
a3f6ca621453
Android: Implement dw_mle_set_visible(). Also fix various warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2706
diff
changeset
|
4008 { |
a3f6ca621453
Android: Implement dw_mle_set_visible(). Also fix various warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2706
diff
changeset
|
4009 waitOnUiThread { |
2716
a1fea6b9f308
Android: Fix potential null pointer exception in mleSetVisible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2715
diff
changeset
|
4010 val layout = mle.layout |
a1fea6b9f308
Android: Fix potential null pointer exception in mleSetVisible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2715
diff
changeset
|
4011 |
a1fea6b9f308
Android: Fix potential null pointer exception in mleSetVisible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2715
diff
changeset
|
4012 if(layout != null) { |
a1fea6b9f308
Android: Fix potential null pointer exception in mleSetVisible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2715
diff
changeset
|
4013 val y: Int = layout.getLineTop(line) |
a1fea6b9f308
Android: Fix potential null pointer exception in mleSetVisible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2715
diff
changeset
|
4014 |
a1fea6b9f308
Android: Fix potential null pointer exception in mleSetVisible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2715
diff
changeset
|
4015 mle.scrollTo(0, y) |
a1fea6b9f308
Android: Fix potential null pointer exception in mleSetVisible().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2715
diff
changeset
|
4016 } |
2707
a3f6ca621453
Android: Implement dw_mle_set_visible(). Also fix various warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2706
diff
changeset
|
4017 } |
a3f6ca621453
Android: Implement dw_mle_set_visible(). Also fix various warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2706
diff
changeset
|
4018 } |
a3f6ca621453
Android: Implement dw_mle_set_visible(). Also fix various warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2706
diff
changeset
|
4019 |
2510
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4020 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
|
4021 { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4022 waitOnUiThread { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4023 if (state != 0) { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4024 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
|
4025 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
|
4026 } else { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4027 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
|
4028 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
|
4029 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4030 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4031 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4032 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4033 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
|
4034 { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4035 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
|
4036 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
|
4037 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4038 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4039 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4040 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
|
4041 { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4042 waitOnUiThread { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4043 mle.setSelection(point) |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4044 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4045 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4046 |
2702
4f12dc8e8f18
Android: Implement dw_mle_set_auto_complete() in the same way as iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2701
diff
changeset
|
4047 fun mleSetAutoComplete(mle: EditText, state: Int) |
4f12dc8e8f18
Android: Implement dw_mle_set_auto_complete() in the same way as iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2701
diff
changeset
|
4048 { |
4f12dc8e8f18
Android: Implement dw_mle_set_auto_complete() in the same way as iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2701
diff
changeset
|
4049 waitOnUiThread { |
4f12dc8e8f18
Android: Implement dw_mle_set_auto_complete() in the same way as iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2701
diff
changeset
|
4050 val inputType = (InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE) |
4f12dc8e8f18
Android: Implement dw_mle_set_auto_complete() in the same way as iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2701
diff
changeset
|
4051 |
4f12dc8e8f18
Android: Implement dw_mle_set_auto_complete() in the same way as iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2701
diff
changeset
|
4052 // DW_MLE_COMPLETE_TEXT 1 |
4f12dc8e8f18
Android: Implement dw_mle_set_auto_complete() in the same way as iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2701
diff
changeset
|
4053 if((state and 1) == 1) { |
4f12dc8e8f18
Android: Implement dw_mle_set_auto_complete() in the same way as iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2701
diff
changeset
|
4054 mle.inputType = (inputType or InputType.TYPE_TEXT_FLAG_AUTO_CORRECT) |
4f12dc8e8f18
Android: Implement dw_mle_set_auto_complete() in the same way as iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2701
diff
changeset
|
4055 } else { |
4f12dc8e8f18
Android: Implement dw_mle_set_auto_complete() in the same way as iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2701
diff
changeset
|
4056 mle.inputType = (inputType or InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) |
4f12dc8e8f18
Android: Implement dw_mle_set_auto_complete() in the same way as iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2701
diff
changeset
|
4057 } |
4f12dc8e8f18
Android: Implement dw_mle_set_auto_complete() in the same way as iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2701
diff
changeset
|
4058 } |
4f12dc8e8f18
Android: Implement dw_mle_set_auto_complete() in the same way as iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2701
diff
changeset
|
4059 } |
4f12dc8e8f18
Android: Implement dw_mle_set_auto_complete() in the same way as iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2701
diff
changeset
|
4060 |
2708
3a7dcc0ae08b
Android: Implement dw_mle_search(). Also revert lowercase() change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2707
diff
changeset
|
4061 fun mleSearch(mle: EditText, text: String, point: Int, flags: Int): Int |
3a7dcc0ae08b
Android: Implement dw_mle_search(). Also revert lowercase() change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2707
diff
changeset
|
4062 { |
3a7dcc0ae08b
Android: Implement dw_mle_search(). Also revert lowercase() change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2707
diff
changeset
|
4063 var retval: Int = -1 |
3a7dcc0ae08b
Android: Implement dw_mle_search(). Also revert lowercase() change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2707
diff
changeset
|
4064 var ignorecase: Boolean = true |
3a7dcc0ae08b
Android: Implement dw_mle_search(). Also revert lowercase() change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2707
diff
changeset
|
4065 |
3a7dcc0ae08b
Android: Implement dw_mle_search(). Also revert lowercase() change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2707
diff
changeset
|
4066 // DW_MLE_CASESENSITIVE 1 |
3a7dcc0ae08b
Android: Implement dw_mle_search(). Also revert lowercase() change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2707
diff
changeset
|
4067 if(flags == 1) { |
3a7dcc0ae08b
Android: Implement dw_mle_search(). Also revert lowercase() change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2707
diff
changeset
|
4068 ignorecase = false |
3a7dcc0ae08b
Android: Implement dw_mle_search(). Also revert lowercase() change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2707
diff
changeset
|
4069 } |
3a7dcc0ae08b
Android: Implement dw_mle_search(). Also revert lowercase() change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2707
diff
changeset
|
4070 |
3a7dcc0ae08b
Android: Implement dw_mle_search(). Also revert lowercase() change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2707
diff
changeset
|
4071 waitOnUiThread { |
3a7dcc0ae08b
Android: Implement dw_mle_search(). Also revert lowercase() change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2707
diff
changeset
|
4072 retval = mle.text.indexOf(text, point, ignorecase) |
3a7dcc0ae08b
Android: Implement dw_mle_search(). Also revert lowercase() change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2707
diff
changeset
|
4073 |
3a7dcc0ae08b
Android: Implement dw_mle_search(). Also revert lowercase() change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2707
diff
changeset
|
4074 if(retval > -1) { |
3a7dcc0ae08b
Android: Implement dw_mle_search(). Also revert lowercase() change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2707
diff
changeset
|
4075 mle.setSelection(retval, retval + text.length) |
3a7dcc0ae08b
Android: Implement dw_mle_search(). Also revert lowercase() change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2707
diff
changeset
|
4076 } |
3a7dcc0ae08b
Android: Implement dw_mle_search(). Also revert lowercase() change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2707
diff
changeset
|
4077 } |
3a7dcc0ae08b
Android: Implement dw_mle_search(). Also revert lowercase() change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2707
diff
changeset
|
4078 return retval |
3a7dcc0ae08b
Android: Implement dw_mle_search(). Also revert lowercase() change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2707
diff
changeset
|
4079 } |
3a7dcc0ae08b
Android: Implement dw_mle_search(). Also revert lowercase() change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2707
diff
changeset
|
4080 |
2510
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4081 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
|
4082 { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4083 waitOnUiThread { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4084 mle.setText("") |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4085 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4086 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4087 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4088 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
|
4089 { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4090 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
|
4091 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4092 waitOnUiThread { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4093 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
|
4094 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
|
4095 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4096 if(startpoint < 1) { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4097 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
|
4098 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4099 mle.setText(newtext) |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4100 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
|
4101 } 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
|
4102 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
|
4103 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4104 mle.setText(newtext) |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4105 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
|
4106 } else { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4107 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
|
4108 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4109 mle.setText(newtext) |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4110 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
|
4111 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4112 mle.setSelection(retval) |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4113 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4114 return retval |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4115 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4116 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4117 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
|
4118 { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4119 waitOnUiThread { |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4120 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
|
4121 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
|
4122 |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4123 mle.setText(newtext) |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4124 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4125 } |
f54051c3f2a5
Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2505
diff
changeset
|
4126 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4127 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
|
4128 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4129 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
|
4130 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4131 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4132 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
|
4133 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
|
4134 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
|
4135 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
|
4136 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
|
4137 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4138 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
|
4139 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
|
4140 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
|
4141 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
|
4142 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
|
4143 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
|
4144 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
|
4145 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
|
4146 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
|
4147 }.attach() |
2488
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
4148 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4149 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
|
4150 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
|
4151 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
|
4152 } else { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4153 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
|
4154 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4155 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
|
4156 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
|
4157 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
|
4158 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
|
4159 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
|
4160 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
|
4161 } else { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4162 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
|
4163 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4164 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
|
4165 // 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
|
4166 // 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
|
4167 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
|
4168 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
|
4169 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
|
4170 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
|
4171 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4172 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
|
4173 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
|
4174 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4175 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4176 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
|
4177 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
|
4178 }) |
2490
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
4179 } |
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
|
4180 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
|
4181 } |
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
|
4182 |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
4183 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
|
4184 { |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
4185 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
|
4186 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4187 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4188 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
|
4189 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
|
4190 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4191 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
|
4192 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
|
4193 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
|
4194 } 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
|
4195 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
|
4196 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
|
4197 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4198 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4199 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
|
4200 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
|
4201 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
|
4202 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4203 // 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
|
4204 do { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4205 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
|
4206 } 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
|
4207 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
|
4208 // 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
|
4209 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
|
4210 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
|
4211 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
|
4212 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
|
4213 ) |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4214 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
|
4215 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
|
4216 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
|
4217 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
|
4218 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
|
4219 } else { |
2682
856d3c8b559f
Android: Fix an exception when displaying a notebook with a placeholder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2681
diff
changeset
|
4220 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
|
4221 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
|
4222 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
|
4223 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
|
4224 } |
2691
e13607b87517
Android: Call notifyDataSetChanged() on ViewPager2 adapters to fix some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2690
diff
changeset
|
4225 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
|
4226 } |
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
|
4227 } |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
4228 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
|
4229 } |
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
|
4230 |
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
|
4231 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
|
4232 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
|
4233 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
|
4234 } |
8352c38bc20b
Android: Turn off Android's forcing buttons and tabs to be all caps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2582
diff
changeset
|
4235 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
|
4236 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
|
4237 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
|
4238 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
|
4239 } 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
|
4240 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
|
4241 } |
8352c38bc20b
Android: Turn off Android's forcing buttons and tabs to be all caps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2582
diff
changeset
|
4242 } |
8352c38bc20b
Android: Turn off Android's forcing buttons and tabs to be all caps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2582
diff
changeset
|
4243 } |
8352c38bc20b
Android: Turn off Android's forcing buttons and tabs to be all caps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2582
diff
changeset
|
4244 |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
4245 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
|
4246 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4247 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4248 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
|
4249 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
|
4250 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4251 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
|
4252 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
|
4253 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
|
4254 } 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
|
4255 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
|
4256 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
|
4257 } |
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
|
4258 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4259 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
|
4260 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
|
4261 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
|
4262 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
|
4263 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4264 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
|
4265 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
|
4266 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
|
4267 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
|
4268 tabs.removeTab(tab) |
2691
e13607b87517
Android: Call notifyDataSetChanged() on ViewPager2 adapters to fix some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2690
diff
changeset
|
4269 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
|
4270 } |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
4271 } |
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
|
4272 } |
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
|
4273 } |
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
|
4274 |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
4275 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
|
4276 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4277 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4278 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
|
4279 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
|
4280 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4281 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
|
4282 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
|
4283 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
|
4284 } 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
|
4285 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
|
4286 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
|
4287 } |
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
|
4288 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4289 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
|
4290 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
|
4291 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
|
4292 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
|
4293 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4294 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
|
4295 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
|
4296 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
|
4297 } |
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
|
4298 |
8352c38bc20b
Android: Turn off Android's forcing buttons and tabs to be all caps.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2582
diff
changeset
|
4299 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
|
4300 } |
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
|
4301 } |
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
|
4302 } |
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
|
4303 |
2736
09775418c776
Android: Use "View" as the type for the viewList instead of LinearLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2735
diff
changeset
|
4304 fun notebookPagePack(notebook: RelativeLayout, pageID: Long, box: View) |
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
|
4305 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4306 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4307 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
|
4308 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
|
4309 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4310 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
|
4311 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
|
4312 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
|
4313 } 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
|
4314 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
|
4315 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
|
4316 } |
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
|
4317 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4318 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
|
4319 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
|
4320 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
|
4321 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4322 // 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
|
4323 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
|
4324 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
|
4325 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
|
4326 ) |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
4327 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4328 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
|
4329 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
|
4330 } |
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
|
4331 } |
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
|
4332 } |
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
|
4333 |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
4334 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
|
4335 { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4336 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
|
4337 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4338 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4339 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
|
4340 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
|
4341 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4342 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
|
4343 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
|
4344 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
|
4345 } 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
|
4346 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
|
4347 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
|
4348 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4349 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4350 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
|
4351 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
|
4352 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
|
4353 } |
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
|
4354 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4355 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
|
4356 } |
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
|
4357 |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
4358 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
|
4359 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4360 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4361 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
|
4362 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
|
4363 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4364 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
|
4365 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
|
4366 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
|
4367 } 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
|
4368 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
|
4369 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
|
4370 } |
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
|
4371 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4372 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
|
4373 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
|
4374 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
|
4375 |
e13607b87517
Android: Call notifyDataSetChanged() on ViewPager2 adapters to fix some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2690
diff
changeset
|
4376 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
|
4377 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
|
4378 pager.setCurrentItem(index, true) |
e13607b87517
Android: Call notifyDataSetChanged() on ViewPager2 adapters to fix some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2690
diff
changeset
|
4379 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4380 } |
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
|
4381 } |
2490
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
4382 } |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
4383 |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4384 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
|
4385 { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4386 var splitbar: ConstraintLayout? = null |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4387 |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4388 waitOnUiThread { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4389 splitbar = ConstraintLayout(this) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4390 if(splitbar != null) { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4391 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
|
4392 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
|
4393 |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4394 constraintSet.clone(splitbar) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4395 |
2656
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
4396 splitbar!!.tag = dataArrayMap |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4397 splitbar!!.id = cid |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4398 |
2656
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
4399 // 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
|
4400 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
|
4401 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
|
4402 |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4403 // Place the top/left item |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4404 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
|
4405 if(topleft.id < 1) { |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4406 topleft.id = View.generateViewId() |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4407 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4408 splitbar!!.addView(topleft) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4409 constraintSet.connect( |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4410 topleft.id, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4411 ConstraintLayout.LayoutParams.TOP, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4412 ConstraintLayout.LayoutParams.PARENT_ID, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4413 ConstraintLayout.LayoutParams.TOP |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4414 ) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4415 constraintSet.connect( |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4416 topleft.id, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4417 ConstraintLayout.LayoutParams.LEFT, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4418 ConstraintLayout.LayoutParams.PARENT_ID, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4419 ConstraintLayout.LayoutParams.LEFT |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4420 ) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4421 |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4422 if (type == 0) { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4423 // Horizontal |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4424 constraintSet.connect( |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4425 topleft.id, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4426 ConstraintLayout.LayoutParams.BOTTOM, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4427 ConstraintLayout.LayoutParams.PARENT_ID, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4428 ConstraintLayout.LayoutParams.BOTTOM |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4429 ) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4430 constraintSet.constrainPercentWidth(topleft.id, 0.5F) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4431 } else { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4432 // Vertical |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4433 constraintSet.connect( |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4434 topleft.id, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4435 ConstraintLayout.LayoutParams.RIGHT, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4436 ConstraintLayout.LayoutParams.PARENT_ID, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4437 ConstraintLayout.LayoutParams.RIGHT |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4438 ) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4439 constraintSet.constrainPercentHeight(topleft.id, 0.5F) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4440 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4441 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4442 |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4443 // Place the bottom/right item |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4444 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
|
4445 if (bottomright.id < 1) { |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4446 bottomright.id = View.generateViewId() |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4447 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4448 splitbar!!.addView(bottomright) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4449 constraintSet.connect( |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4450 bottomright.id, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4451 ConstraintLayout.LayoutParams.BOTTOM, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4452 ConstraintLayout.LayoutParams.PARENT_ID, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4453 ConstraintLayout.LayoutParams.BOTTOM |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4454 ) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4455 constraintSet.connect( |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4456 bottomright.id, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4457 ConstraintLayout.LayoutParams.RIGHT, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4458 ConstraintLayout.LayoutParams.PARENT_ID, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4459 ConstraintLayout.LayoutParams.RIGHT |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4460 ) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4461 |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4462 if (type == 0) { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4463 // Horizontal |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4464 constraintSet.connect( |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4465 bottomright.id, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4466 ConstraintLayout.LayoutParams.TOP, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4467 ConstraintLayout.LayoutParams.PARENT_ID, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4468 ConstraintLayout.LayoutParams.TOP |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4469 ) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4470 constraintSet.constrainPercentWidth(bottomright.id, 0.5F) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4471 } else { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4472 // Vertical |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4473 constraintSet.connect( |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4474 bottomright.id, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4475 ConstraintLayout.LayoutParams.LEFT, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4476 ConstraintLayout.LayoutParams.PARENT_ID, |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4477 ConstraintLayout.LayoutParams.LEFT |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4478 ) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4479 constraintSet.constrainPercentHeight(bottomright.id, 0.5F) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4480 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4481 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4482 |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4483 // 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
|
4484 constraintSet.applyTo(splitbar) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4485 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4486 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4487 return splitbar |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4488 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4489 |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4490 fun splitBarGet(splitbar: ConstraintLayout): Float { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4491 var position: Float = 50.0F |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4492 |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4493 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
|
4494 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
|
4495 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
|
4496 |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
4497 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
|
4498 percent = dataArrayMap.get("_dw_percent")!! |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4499 } |
2656
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
4500 |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
4501 position = percent.toFloat() / 1000000.0F |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4502 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4503 return position |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4504 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4505 |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4506 fun splitBarSet(splitbar: ConstraintLayout, position: Float) { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4507 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
|
4508 val dataArrayMap: SimpleArrayMap<String, Long> = splitbar.tag as SimpleArrayMap<String, Long> |
2707
a3f6ca621453
Android: Implement dw_mle_set_visible(). Also fix various warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2706
diff
changeset
|
4509 val percent: Float = position * 1000000.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
|
4510 |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
4511 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
|
4512 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
|
4513 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
|
4514 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
|
4515 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
|
4516 |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
4517 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
|
4518 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
|
4519 } |
2bdbd5e83654
Android: Save splitbar settings in dataArrayMap instead of attempting to calculate them.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2655
diff
changeset
|
4520 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
|
4521 |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4522 constraintSet.clone(splitbar) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4523 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
|
4524 if (type == 1L) { |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4525 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
|
4526 } else { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4527 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
|
4528 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4529 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4530 if (bottomright != null) { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4531 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
|
4532 if (type == 1L) { |
2650
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4533 constraintSet.constrainPercentHeight(bottomright.id, altper) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4534 } else { |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4535 constraintSet.constrainPercentWidth(bottomright.id, altper) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4536 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4537 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4538 constraintSet.applyTo(splitbar) |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4539 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4540 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4541 } |
7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2643
diff
changeset
|
4542 |
2720
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4543 fun scrollBarNew(vertical: Int, cid: Int): DWSlider? |
2719
6754e8f70142
Android: Split out scrollbar to a separate implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2716
diff
changeset
|
4544 { |
2720
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4545 var scrollbar: DWSlider? = null |
2719
6754e8f70142
Android: Split out scrollbar to a separate implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2716
diff
changeset
|
4546 |
6754e8f70142
Android: Split out scrollbar to a separate implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2716
diff
changeset
|
4547 waitOnUiThread { |
6754e8f70142
Android: Split out scrollbar to a separate implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2716
diff
changeset
|
4548 val dataArrayMap = SimpleArrayMap<String, Long>() |
6754e8f70142
Android: Split out scrollbar to a separate implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2716
diff
changeset
|
4549 |
2720
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4550 scrollbar = DWSlider(this) |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4551 scrollbar!!.tag = dataArrayMap |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4552 scrollbar!!.id = cid |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4553 scrollbar!!.slider.max = 1 |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4554 scrollbar!!.slider.progressTintList = null |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4555 scrollbar!!.slider.progressBackgroundTintList = null |
2719
6754e8f70142
Android: Split out scrollbar to a separate implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2716
diff
changeset
|
4556 if (vertical != 0) { |
2720
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4557 scrollbar!!.slider.rotation = 90F |
2719
6754e8f70142
Android: Split out scrollbar to a separate implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2716
diff
changeset
|
4558 } |
2720
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4559 scrollbar!!.slider.setOnSeekBarChangeListener(object : OnSeekBarChangeListener { |
2719
6754e8f70142
Android: Split out scrollbar to a separate implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2716
diff
changeset
|
4560 override fun onStopTrackingTouch(seekBar: SeekBar) { |
6754e8f70142
Android: Split out scrollbar to a separate implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2716
diff
changeset
|
4561 } |
6754e8f70142
Android: Split out scrollbar to a separate implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2716
diff
changeset
|
4562 |
6754e8f70142
Android: Split out scrollbar to a separate implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2716
diff
changeset
|
4563 override fun onStartTrackingTouch(seekBar: SeekBar) { |
6754e8f70142
Android: Split out scrollbar to a separate implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2716
diff
changeset
|
4564 } |
6754e8f70142
Android: Split out scrollbar to a separate implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2716
diff
changeset
|
4565 |
6754e8f70142
Android: Split out scrollbar to a separate implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2716
diff
changeset
|
4566 override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) { |
2720
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4567 eventHandlerInt(scrollbar as View, DWEvent.VALUE_CHANGED, scrollbar!!.slider.progress, 0, 0, 0) |
2719
6754e8f70142
Android: Split out scrollbar to a separate implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2716
diff
changeset
|
4568 } |
6754e8f70142
Android: Split out scrollbar to a separate implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2716
diff
changeset
|
4569 }) |
6754e8f70142
Android: Split out scrollbar to a separate implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2716
diff
changeset
|
4570 } |
2720
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4571 return scrollbar |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4572 } |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4573 |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4574 fun sliderNew(vertical: Int, increments: Int, cid: Int): DWSlider? |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
4575 { |
2720
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4576 var slider: DWSlider? = null |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4577 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4578 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
4579 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
|
4580 |
2720
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4581 slider = DWSlider(this) |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4582 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
|
4583 slider!!.id = cid |
2720
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4584 slider!!.slider.max = increments |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4585 if (vertical != 0) { |
2720
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4586 slider!!.slider.rotation = 90F |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4587 } |
2720
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4588 slider!!.slider.setOnSeekBarChangeListener(object : OnSeekBarChangeListener { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4589 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
|
4590 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4591 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4592 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
|
4593 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4594 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4595 override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) { |
2720
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4596 eventHandlerInt(slider as View, DWEvent.VALUE_CHANGED, slider!!.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
|
4597 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4598 }) |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
4599 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
4600 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
|
4601 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
4602 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4603 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
|
4604 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4605 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
|
4606 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4607 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
4608 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
|
4609 |
2574
5b13bb267364
Android: Percent widget should be using horizontal ProgressBar.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2573
diff
changeset
|
4610 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
|
4611 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
|
4612 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
|
4613 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
|
4614 } |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
4615 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
|
4616 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
4617 |
2720
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4618 fun percentGetPos(percent: View): Int |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
4619 { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4620 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
|
4621 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4622 waitOnUiThread { |
2720
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4623 var progress: ProgressBar |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4624 |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4625 if(percent is ProgressBar) { |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4626 progress = percent as ProgressBar |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4627 } else { |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4628 val slider = percent as DWSlider |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4629 progress = slider.slider |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4630 } |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4631 retval = progress.progress |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4632 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4633 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
|
4634 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
4635 |
2720
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4636 fun percentSetPos(percent: View, position: Int) |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
4637 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4638 waitOnUiThread { |
2720
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4639 var progress: ProgressBar |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4640 |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4641 if(percent is ProgressBar) { |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4642 progress = percent as ProgressBar |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4643 } else { |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4644 val slider = percent as DWSlider |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4645 progress = slider.slider |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4646 } |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4647 progress.progress = position |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4648 } |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4649 } |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4650 |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4651 fun percentSetRange(percent: View, range: Int) |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
4652 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4653 waitOnUiThread { |
2720
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4654 var progress: ProgressBar |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4655 |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4656 if(percent is ProgressBar) { |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4657 progress = percent as ProgressBar |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4658 } else { |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4659 val slider = percent as DWSlider |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4660 progress = slider.slider |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4661 } |
9ce1649b0fbd
Android: Fix vertical sliders/scrollbars by creating a DWSlider class to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2719
diff
changeset
|
4662 progress.max = range |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4663 } |
2492
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
4664 } |
e2ca6c1a4661
Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2491
diff
changeset
|
4665 |
2501
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
4666 fun htmlNew(cid: Int): WebView? |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
4667 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4668 var html: WebView? = null |
2501
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
4669 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4670 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
4671 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
|
4672 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4673 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
|
4674 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
|
4675 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
|
4676 // 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
|
4677 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
|
4678 html!!.settings.javaScriptEnabled = true |
2501
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
4679 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
4680 return html |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
4681 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
4682 |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
4683 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
|
4684 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4685 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4686 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
|
4687 } |
2501
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
4688 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
4689 |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
4690 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
|
4691 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4692 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4693 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
|
4694 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
|
4695 } |
2501
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
4696 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
4697 |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
4698 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
|
4699 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4700 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4701 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
|
4702 // 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
|
4703 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
|
4704 } |
2501
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
4705 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
4706 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
4707 |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
4708 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
|
4709 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4710 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4711 when (action) { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
4712 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
|
4713 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
|
4714 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
|
4715 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
|
4716 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
|
4717 } |
2501
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
4718 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
4719 } |
41984ffb5ca2
Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2500
diff
changeset
|
4720 |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4721 fun spinButtonNew(text: String, cid: Int): DWSpinButton? |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4722 { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4723 var spinbutton: DWSpinButton? = null |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4724 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4725 waitOnUiThread { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4726 val dataArrayMap = SimpleArrayMap<String, Long>() |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4727 val newval = text.toLongOrNull() |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4728 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4729 spinbutton = DWSpinButton(this) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4730 spinbutton!!.tag = dataArrayMap |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4731 spinbutton!!.id = cid |
2702
4f12dc8e8f18
Android: Implement dw_mle_set_auto_complete() in the same way as iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2701
diff
changeset
|
4732 spinbutton!!.inputType = (InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) |
2520
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4733 spinbutton!!.setText(text) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4734 if(newval != null) { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4735 spinbutton!!.value = newval |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4736 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4737 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4738 return spinbutton |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4739 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4740 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4741 fun spinButtonSetPos(spinbutton: DWSpinButton, position: Long) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4742 { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4743 waitOnUiThread { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4744 spinbutton.value = position |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4745 spinbutton.setText(position.toString()) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4746 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4747 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4748 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4749 fun spinButtonSetLimits(spinbutton: DWSpinButton, upper: Long, lower: Long) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4750 { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4751 waitOnUiThread { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4752 spinbutton.maximum = upper |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4753 spinbutton.minimum = lower |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4754 if(spinbutton.value > upper) { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4755 spinbutton.value = upper |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4756 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4757 if(spinbutton.value < lower) { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4758 spinbutton.value = lower |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4759 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4760 spinbutton.setText(spinbutton.value.toString()) |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4761 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4762 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4763 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4764 fun spinButtonGetPos(spinbutton: DWSpinButton): Long |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4765 { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4766 var retval: Long = 0 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4767 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4768 waitOnUiThread { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4769 val newvalue = spinbutton.text.toString().toLongOrNull() |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4770 |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4771 if(newvalue == null) { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4772 retval = spinbutton.value |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4773 } else { |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4774 retval = newvalue |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4775 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4776 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4777 return retval |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4778 } |
167af4b0004b
Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2519
diff
changeset
|
4779 |
2515
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
4780 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
|
4781 { |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
4782 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
|
4783 |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
4784 waitOnUiThread { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
4785 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
|
4786 |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
4787 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
|
4788 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
|
4789 combobox!!.id = cid |
2702
4f12dc8e8f18
Android: Implement dw_mle_set_auto_complete() in the same way as iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2701
diff
changeset
|
4790 combobox!!.inputType = (InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) |
2517
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
4791 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
|
4792 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
4793 return combobox |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
4794 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
4795 |
2775
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
4796 fun treeNew(cid: Int): DWTree? |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
4797 { |
2775
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
4798 var tree: DWTree? = null |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
4799 |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
4800 waitOnUiThread { |
2775
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
4801 tree = DWTree(this) |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
4802 if(tree != null) { |
2775
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
4803 val dataArrayMap = SimpleArrayMap<String, Long>() |
2774
94af460bb954
Android: Implement dw_tree_new() and verify code doesn't crash.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2773
diff
changeset
|
4804 val factory = object : DWTreeViewHolderFactory { |
94af460bb954
Android: Implement dw_tree_new() and verify code doesn't crash.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2773
diff
changeset
|
4805 override fun getTreeViewHolder(view: View?, layout: Int): DWTreeViewHolder { |
94af460bb954
Android: Implement dw_tree_new() and verify code doesn't crash.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2773
diff
changeset
|
4806 return DWTreeCustomViewHolder(view!!) |
94af460bb954
Android: Implement dw_tree_new() and verify code doesn't crash.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2773
diff
changeset
|
4807 } |
94af460bb954
Android: Implement dw_tree_new() and verify code doesn't crash.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2773
diff
changeset
|
4808 } |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
4809 val treeViewAdapter = DWTreeViewAdapter(factory) |
2775
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
4810 tree!!.tag = dataArrayMap |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
4811 tree!!.id = cid |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
4812 tree!!.adapter = treeViewAdapter |
2782
dff8fb5ddadd
Android: Added layout manager and code to trigger data change updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2781
diff
changeset
|
4813 tree!!.layoutManager = LinearLayoutManager(this) |
2785
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
4814 treeViewAdapter.setTreeItemLongClickListener { treeitem: DWTreeItem?, view: View? -> |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
4815 if(treeitem != null) { |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
4816 eventHandlerTree(tree!!, DWEvent.ITEM_CONTEXT, treeitem, |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
4817 treeitem.getTitle(), treeitem.getData()) |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
4818 } |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
4819 true |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
4820 } |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
4821 treeViewAdapter.setTreeItemClickListener { treeitem: DWTreeItem?, view: View? -> |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
4822 if(treeitem != null) { |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
4823 eventHandlerTree(tree!!, DWEvent.ITEM_SELECT, treeitem, |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
4824 treeitem.getTitle(), treeitem.getData()) |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
4825 } |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
4826 true |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
4827 } |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
4828 treeViewAdapter.setTreeItemExpandListener { treeitem: DWTreeItem?, view: View? -> |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
4829 if(treeitem != null) { |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
4830 eventHandlerTreeItem(tree!!, DWEvent.TREE_EXPAND, treeitem) |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
4831 } |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
4832 true |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
4833 } |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
4834 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
4835 } |
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
4836 return tree |
2774
94af460bb954
Android: Implement dw_tree_new() and verify code doesn't crash.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2773
diff
changeset
|
4837 } |
2773
f207b7ee177f
Android: Experimental Kotlin tree view implmentation, not enabled yet.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2756
diff
changeset
|
4838 |
2776
858155527b05
Android: Minor tree changes... mostly testing my system to push changes to GitHub.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2775
diff
changeset
|
4839 fun treeInsertAfter(tree: DWTree, item: DWTreeItem?, title: String, icon: Drawable, parent: DWTreeItem?, itemdata: Long): DWTreeItem? |
2775
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
4840 { |
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
4841 var treeitem: DWTreeItem? = null |
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
4842 |
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
4843 waitOnUiThread { |
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
4844 var treeViewAdapter = tree.adapter as DWTreeViewAdapter |
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
4845 |
2777
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4846 treeitem = DWTreeItem(title, icon, itemdata, parent) |
2775
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
4847 if(parent == null) { |
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
4848 tree.roots.add(treeitem!!) |
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
4849 } else { |
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
4850 parent.addChild(treeitem!!) |
2777
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4851 } |
2783
1b7c1b6ee760
Android: Fix tree basic functionality... need to add child branches,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2782
diff
changeset
|
4852 tree.updateTree() |
2775
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
4853 } |
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
4854 return treeitem |
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
4855 } |
5f77f52df8ac
Android: Work in progress changes to get the tree working.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2774
diff
changeset
|
4856 |
2777
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4857 fun treeGetTitle(tree: DWTree, item: DWTreeItem): String? |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4858 { |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4859 var retval: String? = null |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4860 |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4861 waitOnUiThread { |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4862 retval = item.getTitle() |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4863 } |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4864 return retval |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4865 } |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4866 |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4867 fun treeGetParent(tree: DWTree, item: DWTreeItem): DWTreeItem? |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4868 { |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4869 var retval: DWTreeItem? = null |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4870 |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4871 waitOnUiThread { |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4872 retval = item.getParent() |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4873 } |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4874 return retval |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4875 } |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4876 |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4877 fun treeItemChange(tree: DWTree, item: DWTreeItem, title: String?, icon: Drawable?) |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4878 { |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4879 waitOnUiThread { |
2782
dff8fb5ddadd
Android: Added layout manager and code to trigger data change updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2781
diff
changeset
|
4880 var changed = false |
dff8fb5ddadd
Android: Added layout manager and code to trigger data change updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2781
diff
changeset
|
4881 |
2777
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4882 if(title != null) { |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4883 item.setTitle(title) |
2782
dff8fb5ddadd
Android: Added layout manager and code to trigger data change updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2781
diff
changeset
|
4884 changed = true |
2777
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4885 } |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4886 if(icon != null) { |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4887 item.setIcon(icon) |
2782
dff8fb5ddadd
Android: Added layout manager and code to trigger data change updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2781
diff
changeset
|
4888 changed = true |
dff8fb5ddadd
Android: Added layout manager and code to trigger data change updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2781
diff
changeset
|
4889 } |
dff8fb5ddadd
Android: Added layout manager and code to trigger data change updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2781
diff
changeset
|
4890 if(changed == true) { |
dff8fb5ddadd
Android: Added layout manager and code to trigger data change updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2781
diff
changeset
|
4891 var treeViewAdapter = tree.adapter as DWTreeViewAdapter |
dff8fb5ddadd
Android: Added layout manager and code to trigger data change updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2781
diff
changeset
|
4892 treeViewAdapter.notifyDataSetChanged() |
2777
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4893 } |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4894 } |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4895 } |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4896 |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4897 fun treeItemSetData(tree: DWTree, item: DWTreeItem, data: Long) |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4898 { |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4899 waitOnUiThread { |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4900 item.setData(data) |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4901 } |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4902 } |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4903 |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4904 fun treeItemGetData(tree: DWTree, item: DWTreeItem): Long |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4905 { |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4906 var retval: Long = 0 |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4907 |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4908 waitOnUiThread { |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4909 retval = item.getData() |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4910 } |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4911 return retval |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4912 } |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4913 |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4914 fun treeItemSelect(tree: DWTree, item: DWTreeItem) |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4915 { |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4916 waitOnUiThread { |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4917 item.setSelected(true) |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4918 } |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4919 } |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4920 |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4921 fun treeItemExpand(tree: DWTree, item: DWTreeItem, state: Int) |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4922 { |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4923 waitOnUiThread { |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4924 val treeViewAdapter = tree.adapter as DWTreeViewAdapter |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4925 |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4926 if(state != 0) { |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4927 treeViewAdapter.expandNode(item) |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4928 } else { |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4929 treeViewAdapter.collapseNode(item) |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4930 } |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4931 } |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4932 } |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4933 |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4934 fun treeItemDelete(tree: DWTree, item: DWTreeItem) |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4935 { |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4936 // TODO: Implement this |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4937 } |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4938 |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4939 fun treeClear(tree: DWTree) |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4940 { |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4941 waitOnUiThread { |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4942 val treeViewAdapter = tree.adapter as DWTreeViewAdapter |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4943 treeViewAdapter.clear() |
2797
62837ceeec46
Android: Fix dw_tree_clear(), need to clear the roots too.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2796
diff
changeset
|
4944 tree.roots.clear() |
2777
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4945 } |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4946 } |
7d7eac751f7d
Android: Connect the C API to the Kotlin tree implementation.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2776
diff
changeset
|
4947 |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
4948 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
|
4949 { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
4950 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
|
4951 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
4952 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
4953 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
|
4954 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
|
4955 |
2834
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
4956 // Save the global container mode into the adapter |
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
4957 adapter.contMode = contMode |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
4958 cont = ListView(this) |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
4959 cont!!.tag = dataArrayMap |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
4960 cont!!.id = cid |
2560
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
4961 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
|
4962 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
|
4963 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
|
4964 } |
2560
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
4965 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
|
4966 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
|
4967 val data = adapter.model.getRowData(position) |
2613
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
4968 val now = System.currentTimeMillis() |
2752
d355c6abbba6
Android: Add a DWContainerRow class implmenting LinearLayout and Checkable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2751
diff
changeset
|
4969 val rowView: DWContainerRow = view as DWContainerRow |
2560
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
4970 |
2563
56183bef6793
Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2562
diff
changeset
|
4971 view.isSelected = !view.isSelected |
2754
e256bd8628ba
Andrdoi: Attempt to fix a number of issues querying containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2753
diff
changeset
|
4972 rowView.toggle() |
2563
56183bef6793
Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2562
diff
changeset
|
4973 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
|
4974 lastClickView = cont!! |
2613
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
4975 // 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
|
4976 // Generate an ENTER event |
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
4977 if(cont!!.choiceMode != ListView.CHOICE_MODE_MULTIPLE || |
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
4978 (position == adapter.lastClickRow && |
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
4979 (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
|
4980 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
|
4981 } else { |
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
4982 // 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
|
4983 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
|
4984 } |
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
4985 adapter.lastClick = now |
72f1141c07aa
Android: Standardize DWContainer behavior part 2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2611
diff
changeset
|
4986 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
|
4987 } |
56183bef6793
Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2562
diff
changeset
|
4988 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
|
4989 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
|
4990 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
|
4991 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
|
4992 |
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
|
4993 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
|
4994 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
|
4995 } |
56183bef6793
Android: Use ItemClick for the ITEM_SELECT event and the API 23
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2562
diff
changeset
|
4996 true |
2560
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
4997 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
4998 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
|
4999 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
|
5000 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
|
5001 |
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
|
5002 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
|
5003 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
|
5004 true |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5005 } |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5006 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5007 return cont |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5008 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5009 |
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
|
5010 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
|
5011 { |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
5012 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
|
5013 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
|
5014 |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
5015 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
|
5016 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
|
5017 } 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
|
5018 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
|
5019 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
|
5020 } 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
|
5021 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
|
5022 } |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
5023 } 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
|
5024 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
|
5025 } |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
5026 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
|
5027 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
|
5028 } 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
|
5029 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
|
5030 } |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
5031 } |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
5032 } |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
5033 |
2754
e256bd8628ba
Andrdoi: Attempt to fix a number of issues querying containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2753
diff
changeset
|
5034 // Create a new SparseBooleanArray with only the true or false contents |
e256bd8628ba
Andrdoi: Attempt to fix a number of issues querying containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2753
diff
changeset
|
5035 private fun onlyBooleanArray(array: SparseBooleanArray, bool: Boolean): SparseBooleanArray |
e256bd8628ba
Andrdoi: Attempt to fix a number of issues querying containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2753
diff
changeset
|
5036 { |
e256bd8628ba
Andrdoi: Attempt to fix a number of issues querying containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2753
diff
changeset
|
5037 val newArray = SparseBooleanArray() |
e256bd8628ba
Andrdoi: Attempt to fix a number of issues querying containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2753
diff
changeset
|
5038 |
e256bd8628ba
Andrdoi: Attempt to fix a number of issues querying containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2753
diff
changeset
|
5039 for (i in 0 until array.size()) { |
e256bd8628ba
Andrdoi: Attempt to fix a number of issues querying containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2753
diff
changeset
|
5040 if (array.valueAt(i) == bool) { |
e256bd8628ba
Andrdoi: Attempt to fix a number of issues querying containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2753
diff
changeset
|
5041 newArray.put(array.keyAt(i), bool) |
e256bd8628ba
Andrdoi: Attempt to fix a number of issues querying containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2753
diff
changeset
|
5042 } |
e256bd8628ba
Andrdoi: Attempt to fix a number of issues querying containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2753
diff
changeset
|
5043 } |
e256bd8628ba
Andrdoi: Attempt to fix a number of issues querying containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2753
diff
changeset
|
5044 return newArray |
e256bd8628ba
Andrdoi: Attempt to fix a number of issues querying containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2753
diff
changeset
|
5045 } |
e256bd8628ba
Andrdoi: Attempt to fix a number of issues querying containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2753
diff
changeset
|
5046 |
2560
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5047 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
|
5048 { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5049 var retval: String? = null |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5050 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5051 waitOnUiThread { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5052 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
|
5053 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5054 // Handle DW_CRA_SELECTED |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5055 if((flags and 1) != 0) { |
2754
e256bd8628ba
Andrdoi: Attempt to fix a number of issues querying containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2753
diff
changeset
|
5056 val checked: SparseBooleanArray = onlyBooleanArray(cont.checkedItemPositions, true) |
2755
9477910393ac
Android: Hopefully the final set of container query fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2754
diff
changeset
|
5057 |
9477910393ac
Android: Hopefully the final set of container query fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2754
diff
changeset
|
5058 if(checked.size() > 0) { |
9477910393ac
Android: Hopefully the final set of container query fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2754
diff
changeset
|
5059 val position = checked.keyAt(0) |
9477910393ac
Android: Hopefully the final set of container query fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2754
diff
changeset
|
5060 |
9477910393ac
Android: Hopefully the final set of container query fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2754
diff
changeset
|
5061 adapter.model.querypos = position |
9477910393ac
Android: Hopefully the final set of container query fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2754
diff
changeset
|
5062 retval = adapter.model.getRowTitle(position) |
9477910393ac
Android: Hopefully the final set of container query fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2754
diff
changeset
|
5063 } else { |
9477910393ac
Android: Hopefully the final set of container query fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2754
diff
changeset
|
5064 adapter.model.querypos = -1 |
9477910393ac
Android: Hopefully the final set of container query fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2754
diff
changeset
|
5065 } |
2560
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5066 } else { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5067 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
|
5068 adapter.model.querypos = -1 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5069 } else { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5070 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
|
5071 adapter.model.querypos = 0 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5072 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5073 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5074 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5075 return retval |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5076 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5077 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5078 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
|
5079 { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5080 var retval: String? = null |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5081 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5082 waitOnUiThread { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5083 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
|
5084 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5085 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
|
5086 // Handle DW_CRA_SELECTED |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5087 if ((flags and 1) != 0) { |
2754
e256bd8628ba
Andrdoi: Attempt to fix a number of issues querying containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2753
diff
changeset
|
5088 val checked: SparseBooleanArray = onlyBooleanArray(cont.checkedItemPositions, true) |
2560
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5089 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5090 // 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
|
5091 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
|
5092 // Item position in adapter |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5093 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
|
5094 |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
5095 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
|
5096 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
|
5097 |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
5098 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
|
5099 retval = adapter.model.getRowTitle(newpos) |
2755
9477910393ac
Android: Hopefully the final set of container query fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2754
diff
changeset
|
5100 break |
2560
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5101 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5102 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5103 } else { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5104 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
|
5105 adapter.model.querypos += 1 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5106 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
|
5107 } else { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5108 adapter.model.querypos = -1 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5109 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5110 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5111 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5112 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5113 return retval |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5114 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5115 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5116 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
|
5117 { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5118 var retval: Long = 0 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5119 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5120 waitOnUiThread { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5121 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
|
5122 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5123 // Handle DW_CRA_SELECTED |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5124 if((flags and 1) != 0) { |
2754
e256bd8628ba
Andrdoi: Attempt to fix a number of issues querying containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2753
diff
changeset
|
5125 val checked: SparseBooleanArray = onlyBooleanArray(cont.checkedItemPositions, true) |
2755
9477910393ac
Android: Hopefully the final set of container query fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2754
diff
changeset
|
5126 |
9477910393ac
Android: Hopefully the final set of container query fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2754
diff
changeset
|
5127 if(checked.size() > 0) { |
9477910393ac
Android: Hopefully the final set of container query fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2754
diff
changeset
|
5128 val position = checked.keyAt(0) |
9477910393ac
Android: Hopefully the final set of container query fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2754
diff
changeset
|
5129 |
9477910393ac
Android: Hopefully the final set of container query fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2754
diff
changeset
|
5130 adapter.model.querypos = position |
9477910393ac
Android: Hopefully the final set of container query fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2754
diff
changeset
|
5131 retval = adapter.model.getRowData(position) |
9477910393ac
Android: Hopefully the final set of container query fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2754
diff
changeset
|
5132 } else { |
9477910393ac
Android: Hopefully the final set of container query fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2754
diff
changeset
|
5133 adapter.model.querypos = -1 |
9477910393ac
Android: Hopefully the final set of container query fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2754
diff
changeset
|
5134 } |
2560
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5135 } else { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5136 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
|
5137 adapter.model.querypos = -1 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5138 } else { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5139 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
|
5140 adapter.model.querypos = 0 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5141 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5142 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5143 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5144 return retval |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5145 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5146 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5147 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
|
5148 { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5149 var retval: Long = 0 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5150 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5151 waitOnUiThread { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5152 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
|
5153 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5154 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
|
5155 // Handle DW_CRA_SELECTED |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5156 if ((flags and 1) != 0) { |
2754
e256bd8628ba
Andrdoi: Attempt to fix a number of issues querying containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2753
diff
changeset
|
5157 val checked: SparseBooleanArray = onlyBooleanArray(cont.checkedItemPositions, true) |
2560
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5158 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5159 // 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
|
5160 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
|
5161 // Item position in adapter |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5162 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
|
5163 |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
5164 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
|
5165 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
|
5166 |
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
5167 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
|
5168 retval = adapter.model.getRowData(newpos) |
2755
9477910393ac
Android: Hopefully the final set of container query fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2754
diff
changeset
|
5169 break |
2560
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5170 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5171 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5172 } else { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5173 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
|
5174 adapter.model.querypos += 1 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5175 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
|
5176 } else { |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5177 adapter.model.querypos = -1 |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5178 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5179 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5180 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5181 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5182 return retval |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5183 } |
3da35cd91ca7
Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2558
diff
changeset
|
5184 |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5185 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
|
5186 { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5187 waitOnUiThread { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5188 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
|
5189 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5190 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
|
5191 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5192 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5193 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5194 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
|
5195 { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5196 waitOnUiThread { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5197 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
|
5198 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
|
5199 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5200 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
|
5201 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5202 return cont |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5203 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5204 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5205 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
|
5206 { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5207 waitOnUiThread { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5208 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
|
5209 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5210 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
|
5211 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5212 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5213 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5214 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
|
5215 { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5216 waitOnUiThread { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5217 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
|
5218 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5219 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
|
5220 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5221 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5222 |
2833
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5223 fun containerChangeItemInt(cont: ListView, column: Int, row: Int, num: Long) |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5224 { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5225 waitOnUiThread { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5226 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
|
5227 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5228 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
|
5229 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5230 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5231 |
2834
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
5232 fun timeString(num: Int, zeroAllowed: Boolean): String |
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
5233 { |
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
5234 if(zeroAllowed && num == 0) |
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
5235 return "00" |
2833
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5236 if(num > 0 && num < 60) { |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5237 if(num > 9) |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5238 return num.toString() |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5239 else |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5240 return "0" + num.toString() |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5241 } |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5242 return "01" |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5243 } |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5244 |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5245 fun yearString(year: Int): String |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5246 { |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5247 if(year < 100) |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5248 { |
2834
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
5249 if(year > 69) |
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
5250 return "19" + timeString(year, false) |
2833
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5251 else |
2834
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
5252 return "20" + timeString(year, true) |
2833
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5253 } |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5254 if(year in 1901..2199) |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5255 return year.toString() |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5256 val calendar = Calendar.getInstance() |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5257 val thisyear = calendar[Calendar.YEAR] |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5258 return thisyear.toString() |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5259 } |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5260 |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5261 fun containerChangeItemDate(cont: ListView, column: Int, row: Int, year: Int, month: Int, day: Int) |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5262 { |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5263 waitOnUiThread { |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5264 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter |
2834
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
5265 val dateString = timeString(day, false) + "/" + timeString(month, false) + "/" + yearString(year) |
2833
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5266 val sdf = SimpleDateFormat("dd/MM/yyyy") |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5267 var date: Date? = null |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5268 var s = dateString |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5269 try { |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5270 date = sdf.parse(dateString) |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5271 val dateFormat = DateFormat.getDateFormat(this) |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5272 s = dateFormat.format(date) |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5273 } catch (e: ParseException) { |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5274 // handle exception here ! |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5275 } |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5276 adapter.model.setRowAndColumn(row, column, s) |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5277 } |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5278 } |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5279 |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5280 fun containerChangeItemTime(cont: ListView, column: Int, row: Int, hour: Int, minute: Int, second: Int) |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5281 { |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5282 waitOnUiThread { |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5283 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter |
2834
0cbe8201db3c
Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2833
diff
changeset
|
5284 val timeStr = timeString(hour, true) + ":" + timeString(minute, true) + ":" + timeString(second, true) |
2833
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5285 val sdf = SimpleDateFormat("hh:mm:ss") |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5286 var date: Date? = null |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5287 var s = timeStr |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5288 try { |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5289 date = sdf.parse(timeStr) |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5290 val timeFormat = DateFormat.getTimeFormat(this) |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5291 s = timeFormat.format(date) |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5292 } catch (e: ParseException) { |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5293 // handle exception here ! |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5294 } |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5295 adapter.model.setRowAndColumn(row, column, s) |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5296 } |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5297 } |
469e5748c8a5
Android: In preparation for the container mode changes... I needed to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2809
diff
changeset
|
5298 |
2558
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5299 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
|
5300 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5301 waitOnUiThread { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5302 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
|
5303 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5304 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
|
5305 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5306 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5307 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5308 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
|
5309 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5310 waitOnUiThread { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5311 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
|
5312 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5313 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
|
5314 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5315 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5316 |
2561
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
5317 fun containerRefresh(cont: ListView) |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
5318 { |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
5319 waitOnUiThread { |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
5320 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
|
5321 |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
5322 adapter.notifyDataSetChanged() |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
5323 } |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
5324 } |
f28d7d0ca5ed
Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2560
diff
changeset
|
5325 |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5326 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
|
5327 { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
5328 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
|
5329 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5330 waitOnUiThread { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5331 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
|
5332 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5333 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
|
5334 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5335 return type |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5336 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5337 |
2558
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5338 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
|
5339 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5340 waitOnUiThread { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5341 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
|
5342 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5343 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
|
5344 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5345 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5346 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5347 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
|
5348 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5349 waitOnUiThread { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5350 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
|
5351 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5352 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
|
5353 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5354 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5355 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5356 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
|
5357 { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5358 waitOnUiThread { |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5359 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
|
5360 |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5361 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
|
5362 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5363 } |
ebc6a4ff5f1f
Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2557
diff
changeset
|
5364 |
2556
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5365 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
|
5366 { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5367 waitOnUiThread { |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5368 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
|
5369 |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5370 adapter.model.clear() |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5371 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5372 } |
d2d8c66ad062
Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2555
diff
changeset
|
5373 |
2709
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5374 fun containerScroll(cont: ListView, direction: Int, rows: Int) |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5375 { |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5376 waitOnUiThread { |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5377 // DW_SCROLL_UP 0 |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5378 if(direction == 0) { |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5379 cont.smoothScrollByOffset(-rows) |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5380 // DW_SCROLL_DOWN 1 |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5381 } else if(direction == 1) { |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5382 cont.smoothScrollByOffset(rows) |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5383 // DW_SCROLL_TOP 2 |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5384 } else if(direction == 2) { |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5385 cont.setSelection(0) |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5386 cont.smoothScrollToPosition(0) |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5387 // DW_SCROLL_BOTTOM 3 |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5388 } else if(direction == 3) { |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5389 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5390 val pos = adapter.model.rowdata.size |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5391 |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5392 if(pos > 0) { |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5393 cont.setSelection(pos - 1) |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5394 cont.smoothScrollToPosition(pos - 1) |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5395 } |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5396 } |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5397 } |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5398 } |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5399 |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5400 fun containerCursor(cont: ListView, title: String?) |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5401 { |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5402 waitOnUiThread { |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5403 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5404 val pos = adapter.model.positionByTitle(title) |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5405 |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5406 if(pos > -1) { |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5407 cont.setSelection(pos) |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5408 cont.smoothScrollToPosition(pos) |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5409 } |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5410 |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5411 } |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5412 } |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5413 |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5414 fun containerCursorByData(cont: ListView, rdata: Long) |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5415 { |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5416 waitOnUiThread { |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5417 val adapter: DWContainerAdapter = cont.adapter as DWContainerAdapter |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5418 val pos = adapter.model.positionByData(rdata) |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5419 |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5420 if(pos > -1) { |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5421 cont.setSelection(pos) |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5422 cont.smoothScrollToPosition(pos) |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5423 } |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5424 |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5425 } |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5426 } |
3cb5aa73dace
Android: Implement dw_container_scroll(), dw_container_cursor() and dw_container_cursor_by_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2708
diff
changeset
|
5427 |
2519
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
5428 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
|
5429 { |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
5430 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
|
5431 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
5432 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
5433 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
|
5434 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
5435 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
|
5436 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
|
5437 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
|
5438 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
|
5439 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
|
5440 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
5441 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
5442 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
|
5443 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
5444 |
2515
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
5445 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
|
5446 { |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
5447 waitOnUiThread { |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
5448 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
|
5449 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
|
5450 |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
5451 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
|
5452 } 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
|
5453 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
|
5454 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
5455 listbox.list.add(text) |
2753
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
5456 listbox.multiple.clear() |
2690
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
5457 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
|
5458 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
|
5459 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
5460 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
5461 } |
211044d98e86
Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2514
diff
changeset
|
5462 |
2517
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5463 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
|
5464 { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5465 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5466 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
|
5467 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5468 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5469 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
|
5470 } 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
|
5471 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
|
5472 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
5473 listbox.list.add(pos, text) |
2753
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
5474 listbox.multiple.clear() |
2690
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
5475 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
|
5476 adapter.notifyDataSetChanged() |
2517
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5477 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5478 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5479 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5480 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5481 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
|
5482 { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5483 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5484 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
|
5485 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5486 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5487 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
|
5488 } 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
|
5489 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
|
5490 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
5491 listbox.list.clear() |
2753
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
5492 listbox.multiple.clear() |
2690
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
5493 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
|
5494 adapter.notifyDataSetChanged() |
2517
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5495 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5496 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5497 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5498 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5499 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
|
5500 { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
5501 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
|
5502 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5503 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5504 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
|
5505 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5506 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5507 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
|
5508 } 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
|
5509 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
|
5510 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
5511 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
|
5512 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5513 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5514 return retval |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5515 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5516 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5517 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
|
5518 { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5519 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5520 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
|
5521 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5522 |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
5523 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
|
5524 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
|
5525 } 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
|
5526 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
|
5527 |
2690
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
5528 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
|
5529 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
|
5530 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
|
5531 adapter.notifyDataSetChanged() |
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
5532 } |
2517
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5533 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5534 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5535 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5536 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5537 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
|
5538 { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5539 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
|
5540 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5541 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5542 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
|
5543 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5544 |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
5545 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
|
5546 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
|
5547 } 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
|
5548 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
|
5549 |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
5550 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
|
5551 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
|
5552 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5553 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5554 return retval |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5555 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5556 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5557 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
|
5558 { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5559 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
|
5560 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5561 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5562 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
|
5563 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5564 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5565 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
|
5566 } 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
|
5567 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
|
5568 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
5569 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
|
5570 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5571 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5572 return retval |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5573 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5574 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5575 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
|
5576 { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5577 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5578 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
|
5579 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5580 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5581 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
|
5582 combobox.selected = index |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5583 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
|
5584 } |
2519
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
5585 } 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
|
5586 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
|
5587 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
5588 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
|
5589 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
|
5590 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
|
5591 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
|
5592 } else { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
5593 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
|
5594 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
5595 } |
2517
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5596 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5597 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5598 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5599 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5600 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
|
5601 { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5602 waitOnUiThread { |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5603 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
|
5604 val combobox = window |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5605 |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5606 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
|
5607 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
|
5608 } |
2519
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
5609 } 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
|
5610 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
|
5611 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
5612 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
|
5613 listbox.list.removeAt(index) |
2753
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
5614 listbox.multiple.clear() |
2690
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
5615 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
|
5616 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
|
5617 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
5618 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
5619 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
5620 } |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
5621 |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
5622 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
|
5623 { |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
5624 waitOnUiThread { |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
5625 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
|
5626 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
|
5627 |
551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2517
diff
changeset
|
5628 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
|
5629 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
|
5630 } |
2517
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5631 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5632 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5633 } |
d746323f2841
Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2516
diff
changeset
|
5634 |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
5635 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
|
5636 { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
5637 var retval: Int = -1 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
5638 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
5639 waitOnUiThread { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
5640 if(window is DWListBox) { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
5641 val listbox = window |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
5642 |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
5643 // If we are starting over.... |
2753
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
5644 if(where == -1 && listbox.multiple.count() > 0) { |
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
5645 retval = listbox.multiple[0] |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
5646 } else { |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
5647 // Otherwise loop until we find our current place |
2753
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
5648 for (i in 0 until listbox.multiple.count()) { |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
5649 // Item position in adapter |
2753
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
5650 val position: Int = listbox.multiple[i] |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
5651 // 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
|
5652 // 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
|
5653 // otherwise we will return -1 to indicated we are done. |
2753
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
5654 if (where == position && (i+1) < listbox.multiple.count()) { |
2ac361d3a837
Android: Rewrite listbox multiple selection... keep track of the selection
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2752
diff
changeset
|
5655 retval = listbox.multiple[i+1] |
2521
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
5656 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
5657 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
5658 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
5659 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
5660 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
5661 return retval |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
5662 } |
5f92284e2b08
Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2520
diff
changeset
|
5663 |
2523
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
5664 fun calendarNew(cid: Int): CalendarView? |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
5665 { |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
5666 var calendar: CalendarView? = null |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
5667 |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
5668 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
5669 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
|
5670 |
2523
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
5671 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
|
5672 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
|
5673 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
|
5674 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
|
5675 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
|
5676 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
|
5677 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
|
5678 } |
2523
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
5679 } |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
5680 |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
5681 return calendar |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
5682 } |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
5683 |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
5684 fun calendarSetDate(calendar: CalendarView, date: Long) |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
5685 { |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
5686 waitOnUiThread { |
2524
d5c3c573c74e
Android: Calendar fixes, need to be in milliseconds not seconds... also...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2523
diff
changeset
|
5687 // 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
|
5688 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
|
5689 } |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
5690 } |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
5691 |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
5692 fun calendarGetDate(calendar: CalendarView): Long |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
5693 { |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
5694 var date: Long = 0 |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
5695 |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
5696 waitOnUiThread { |
2524
d5c3c573c74e
Android: Calendar fixes, need to be in milliseconds not seconds... also...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2523
diff
changeset
|
5697 // 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
|
5698 date = calendar.date / 1000 |
2523
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
5699 } |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
5700 return date |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
5701 } |
82cdb3ad7c25
Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2522
diff
changeset
|
5702 |
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
|
5703 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
|
5704 { |
03f6870bcfcc
Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2527
diff
changeset
|
5705 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
|
5706 |
03f6870bcfcc
Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2527
diff
changeset
|
5707 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
5708 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
|
5709 |
03f6870bcfcc
Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2527
diff
changeset
|
5710 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
|
5711 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
|
5712 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
|
5713 } |
03f6870bcfcc
Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2527
diff
changeset
|
5714 |
03f6870bcfcc
Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2527
diff
changeset
|
5715 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
|
5716 } |
03f6870bcfcc
Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2527
diff
changeset
|
5717 |
2654
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
5718 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
|
5719 { |
03f6870bcfcc
Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2527
diff
changeset
|
5720 waitOnUiThread { |
2654
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
5721 var filename: String? = file |
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
5722 |
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
5723 if(resID > 0 && resID < 65536) { |
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
5724 filename = resID.toString() |
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
5725 } else if(resID != 0) { |
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
5726 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
|
5727 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
|
5728 |
03f6870bcfcc
Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2527
diff
changeset
|
5729 button.setImageResource(resID) |
2654
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
5730 } 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
|
5731 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
|
5732 |
03f6870bcfcc
Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2527
diff
changeset
|
5733 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
|
5734 } |
2654
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
5735 } |
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
5736 if(filename != null) { |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
5737 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
|
5738 // 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
|
5739 try { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
5740 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
|
5741 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
|
5742 |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
5743 if(b != null) { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
5744 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
|
5745 val button = window |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
5746 |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
5747 button.setImageBitmap(b) |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
5748 } 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
|
5749 val imageview = window |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
5750 |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
5751 imageview.setImageBitmap(b) |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
5752 } |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
5753 break |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
5754 } |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
5755 } 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
|
5756 } |
03f6870bcfcc
Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2527
diff
changeset
|
5757 } |
03f6870bcfcc
Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2527
diff
changeset
|
5758 } |
03f6870bcfcc
Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2527
diff
changeset
|
5759 } |
03f6870bcfcc
Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2527
diff
changeset
|
5760 } |
03f6870bcfcc
Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2527
diff
changeset
|
5761 |
03f6870bcfcc
Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2527
diff
changeset
|
5762 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
|
5763 { |
03f6870bcfcc
Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2527
diff
changeset
|
5764 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
|
5765 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
|
5766 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
|
5767 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
|
5768 |
03f6870bcfcc
Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2527
diff
changeset
|
5769 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
|
5770 } 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
|
5771 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
|
5772 |
03f6870bcfcc
Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2527
diff
changeset
|
5773 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
|
5774 } |
2655
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
5775 } |
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
5776 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
|
5777 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
|
5778 |
03f6870bcfcc
Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2527
diff
changeset
|
5779 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
|
5780 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
|
5781 |
03f6870bcfcc
Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2527
diff
changeset
|
5782 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
|
5783 } 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
|
5784 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
|
5785 |
03f6870bcfcc
Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2527
diff
changeset
|
5786 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
|
5787 } |
03f6870bcfcc
Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2527
diff
changeset
|
5788 } |
03f6870bcfcc
Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2527
diff
changeset
|
5789 } |
03f6870bcfcc
Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2527
diff
changeset
|
5790 } |
03f6870bcfcc
Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2527
diff
changeset
|
5791 |
2652
42151fd096d4
Android: Switch to loading resource images like we do on iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2651
diff
changeset
|
5792 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
|
5793 { |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
5794 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
|
5795 |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
5796 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
|
5797 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
|
5798 |
42151fd096d4
Android: Switch to loading resource images like we do on iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2651
diff
changeset
|
5799 // 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
|
5800 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
|
5801 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
|
5802 // 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
|
5803 } 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
|
5804 try { |
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
5805 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
|
5806 } 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
|
5807 } |
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
5808 // 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
|
5809 } 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
|
5810 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
|
5811 } else { |
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
5812 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
|
5813 } |
42151fd096d4
Android: Switch to loading resource images like we do on iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2651
diff
changeset
|
5814 // 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
|
5815 // 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
|
5816 if(filename != null) { |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
5817 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
|
5818 // 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
|
5819 try { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
5820 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
|
5821 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
|
5822 } catch (e: IOException) { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
5823 } |
2652
42151fd096d4
Android: Switch to loading resource images like we do on iOS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2651
diff
changeset
|
5824 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
|
5825 break |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
5826 } |
2530
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
5827 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
5828 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
5829 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
5830 return icon |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
5831 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
5832 |
2654
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
5833 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
|
5834 { |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
5835 var pixmap: Bitmap? = null |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
5836 |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
5837 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
|
5838 var filename: String? = null |
2654
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
5839 |
2529
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
5840 if(width > 0 && height > 0) { |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
5841 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
|
5842 } 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
|
5843 filename = resID.toString() |
2529
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
5844 } 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
|
5845 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
|
5846 } 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
|
5847 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
|
5848 } else { |
5b63a3ed8e10
Android: Code path cleanup, basically only try one image load... the only
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2654
diff
changeset
|
5849 filename = file |
2654
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
5850 } |
fe186c9318cc
Android: More resource changes, for windowSetBitmap and pixmapNew.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2653
diff
changeset
|
5851 if(filename != null) { |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
5852 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
|
5853 // 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
|
5854 try { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
5855 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
|
5856 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
|
5857 } catch (e: IOException) { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
5858 } |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
5859 if(pixmap != null) { |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
5860 break |
607acfe2c504
Android: The *_from_file() functions now check the assets folder.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2563
diff
changeset
|
5861 } |
2529
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
5862 } |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
5863 } |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
5864 } |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
5865 return pixmap |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
5866 } |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
5867 |
2727
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
5868 fun printRun(print: Long, flags: Int, jobname: String, pages: Int, runflags: Int): PrintJob? |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
5869 { |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
5870 var retval: PrintJob? = null |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
5871 |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
5872 waitOnUiThread { |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
5873 // Get a PrintManager instance |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
5874 val printManager = this.getSystemService(Context.PRINT_SERVICE) as PrintManager |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
5875 // Setup our print adapter |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
5876 val printAdapter = DWPrintDocumentAdapter() |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
5877 printAdapter.context = this |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
5878 printAdapter.pages = pages |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
5879 printAdapter.print = print |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
5880 // Start a print job, passing in a PrintDocumentAdapter implementation |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
5881 // to handle the generation of a print document |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
5882 retval = printManager.print(jobname, printAdapter, null) |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
5883 } |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
5884 return retval |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
5885 } |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
5886 |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
5887 fun printCancel(printjob: PrintJob) |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
5888 { |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
5889 waitOnUiThread { |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
5890 // Get a PrintManager instance |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
5891 val printManager = this.getSystemService(Context.PRINT_SERVICE) as PrintManager |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
5892 // Remove the job we earlier added from the queue |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
5893 printManager.printJobs.remove(printjob) |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
5894 } |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
5895 } |
bf585f375286
Android: Initial print implementation for Android....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2722
diff
changeset
|
5896 |
2529
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
5897 fun pixmapGetDimensions(pixmap: Bitmap): Long |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
5898 { |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
5899 var dimensions: Long = 0 |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
5900 |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
5901 waitOnUiThread { |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
5902 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
|
5903 } |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
5904 return dimensions |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
5905 } |
060fdb2d807d
Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2528
diff
changeset
|
5906 |
2542
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
5907 fun screenGetDimensions(): Long |
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
5908 { |
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
5909 val dm = resources.displayMetrics |
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
5910 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
|
5911 } |
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
5912 |
2530
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
5913 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
|
5914 { |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
5915 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
|
5916 |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
5917 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
5918 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
|
5919 |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
5920 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
|
5921 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
|
5922 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
|
5923 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
|
5924 @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
|
5925 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
|
5926 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
|
5927 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
|
5928 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
|
5929 render!!.evy = event.y |
2611
ed2c4a503666
Android: Implement button release and motion notify events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2608
diff
changeset
|
5930 // 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
|
5931 // 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
|
5932 } |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
5933 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
|
5934 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
|
5935 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
|
5936 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
|
5937 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
|
5938 } |
ed2c4a503666
Android: Implement button release and motion notify events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2608
diff
changeset
|
5939 MotionEvent.ACTION_MOVE -> { |
ed2c4a503666
Android: Implement button release and motion notify events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2608
diff
changeset
|
5940 render!!.evx = event.x |
ed2c4a503666
Android: Implement button release and motion notify events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2608
diff
changeset
|
5941 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
|
5942 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
|
5943 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
|
5944 } |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
5945 } |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
5946 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
|
5947 } |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
5948 }) |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
5949 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
|
5950 // 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
|
5951 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
|
5952 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
|
5953 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
|
5954 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
|
5955 } |
a11522c30345
Android: Add initial code to handle button presses and long clicks on DWRender.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2607
diff
changeset
|
5956 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
|
5957 // 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
|
5958 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
|
5959 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
|
5960 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
|
5961 } |
2596
60ec91d23746
Android: Add initial keyboard support for Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2595
diff
changeset
|
5962 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
|
5963 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
|
5964 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
|
5965 } |
60ec91d23746
Android: Add initial keyboard support for Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2595
diff
changeset
|
5966 false |
60ec91d23746
Android: Add initial keyboard support for Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2595
diff
changeset
|
5967 }) |
2530
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
5968 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
5969 return render |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
5970 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
5971 |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
5972 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
|
5973 { |
2539
822f814a54f4
Android: Fix memory corruption issue due to incorrectly allocating HPIXMAP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2538
diff
changeset
|
5974 runOnUiThread { |
822f814a54f4
Android: Fix memory corruption issue due to incorrectly allocating HPIXMAP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2538
diff
changeset
|
5975 render.invalidate() |
822f814a54f4
Android: Fix memory corruption issue due to incorrectly allocating HPIXMAP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2538
diff
changeset
|
5976 } |
2530
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
5977 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
5978 |
2531
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
5979 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
|
5980 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
|
5981 { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
5982 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
|
5983 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
|
5984 var retval = 1 |
2531
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
5985 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
5986 if(srcw == -1) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
5987 src.right = srcx + dstw |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
5988 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
5989 if(srch == -1) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
5990 src.bottom = srcy + dsth |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
5991 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
5992 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
5993 waitOnUiThread { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
5994 var canvas: Canvas? = null |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
5995 var bitmap: Bitmap? = null |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
5996 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
5997 if(dstr != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
5998 canvas = dstr.cachedCanvas |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
5999 } else if(dstp != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6000 canvas = Canvas(dstp) |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6001 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6002 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6003 if(srcp != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6004 bitmap = srcp |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6005 } else if(srcr != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6006 bitmap = Bitmap.createBitmap(srcr.layoutParams.width, |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6007 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
|
6008 val c = Canvas(bitmap) |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6009 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
|
6010 srcr.draw(c) |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6011 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6012 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6013 if(canvas != null && bitmap != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6014 canvas.drawBitmap(bitmap, src, dst, null) |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6015 retval = 0 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6016 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6017 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6018 return retval |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6019 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6020 |
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
|
6021 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
|
6022 { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6023 waitOnUiThread { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6024 var canvas: Canvas? = null |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6025 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6026 if(render != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6027 canvas = render.cachedCanvas |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6028 } else if(bitmap != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6029 canvas = Canvas(bitmap) |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6030 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6031 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6032 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
|
6033 colorsSet(fgColor, bgColor) |
2531
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6034 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
|
6035 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6036 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6037 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6038 |
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
|
6039 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
|
6040 { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6041 waitOnUiThread { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6042 var canvas: Canvas? = null |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6043 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6044 if(render != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6045 canvas = render.cachedCanvas |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6046 } else if(bitmap != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6047 canvas = Canvas(bitmap) |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6048 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6049 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6050 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
|
6051 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
|
6052 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
|
6053 paint.style = Paint.Style.STROKE |
2531
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6054 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
|
6055 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6056 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6057 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6058 |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
6059 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
|
6060 { |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
6061 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
|
6062 |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
6063 waitOnUiThread { |
2578
a36448beb7f7
Android: Implement dw_window_set_style() for static text widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2576
diff
changeset
|
6064 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
|
6065 |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
6066 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
|
6067 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
|
6068 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
|
6069 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
|
6070 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
|
6071 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
6072 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
6073 } 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
|
6074 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
|
6075 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
|
6076 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
|
6077 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
|
6078 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
6079 } 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
|
6080 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
|
6081 |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
6082 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
|
6083 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
|
6084 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
|
6085 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
|
6086 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
6087 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
6088 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
6089 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
6090 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
|
6091 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
|
6092 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
|
6093 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
|
6094 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
6095 return dimensions |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
6096 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
6097 |
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
|
6098 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
|
6099 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
|
6100 { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6101 waitOnUiThread { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6102 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
|
6103 |
2547
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
6104 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
|
6105 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
|
6106 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
|
6107 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
|
6108 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
|
6109 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
|
6110 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
6111 } |
2535
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6112 } 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
|
6113 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
|
6114 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
|
6115 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
|
6116 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
|
6117 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
|
6118 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
6119 } 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
|
6120 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
|
6121 |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
6122 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
|
6123 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
|
6124 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
|
6125 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
|
6126 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
6127 } |
dbd15c13f5bb
Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2546
diff
changeset
|
6128 } |
2535
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6129 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6130 |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6131 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
|
6132 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
|
6133 // 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
|
6134 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
|
6135 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
|
6136 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
|
6137 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
|
6138 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
|
6139 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
|
6140 if(bgcolor != null) { |
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
6141 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
|
6142 // 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
|
6143 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
|
6144 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
|
6145 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
|
6146 rect.left += x |
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
6147 rect.right += x |
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
6148 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
|
6149 // 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
|
6150 paint.color = oldcolor |
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
6151 } |
2535
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6152 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
|
6153 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
|
6154 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6155 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6156 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6157 |
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
|
6158 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
|
6159 { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6160 waitOnUiThread { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6161 var canvas: Canvas? = null |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6162 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6163 if(render != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6164 canvas = render.cachedCanvas |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6165 } else if(bitmap != null) { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6166 canvas = Canvas(bitmap) |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6167 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6168 |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6169 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
|
6170 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
|
6171 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
|
6172 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
|
6173 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
|
6174 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6175 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6176 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6177 |
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
|
6178 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
|
6179 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
|
6180 { |
2537
cd9d2ba251d5
Android: Reimplement drawPolygon() using drawPath() instead of drawLines/Points().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2536
diff
changeset
|
6181 // 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
|
6182 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
|
6183 |
2537
cd9d2ba251d5
Android: Reimplement drawPolygon() using drawPath() instead of drawLines/Points().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2536
diff
changeset
|
6184 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
|
6185 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
|
6186 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
|
6187 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6188 |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6189 waitOnUiThread { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6190 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
|
6191 |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6192 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
|
6193 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
|
6194 } 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
|
6195 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
|
6196 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6197 |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6198 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
|
6199 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
|
6200 // 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
|
6201 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
|
6202 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
|
6203 } else { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6204 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
|
6205 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6206 // 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
|
6207 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
|
6208 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
|
6209 } else { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6210 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
|
6211 } |
2537
cd9d2ba251d5
Android: Reimplement drawPolygon() using drawPath() instead of drawLines/Points().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2536
diff
changeset
|
6212 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
|
6213 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6214 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6215 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6216 |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6217 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
|
6218 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
|
6219 { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6220 waitOnUiThread { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6221 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
|
6222 |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6223 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
|
6224 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
|
6225 } 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
|
6226 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
|
6227 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6228 |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6229 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
|
6230 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
|
6231 |
2535
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6232 // 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
|
6233 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
|
6234 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
|
6235 } else { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6236 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
|
6237 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6238 // 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
|
6239 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
|
6240 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
|
6241 } else { |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6242 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
|
6243 } |
2536
d172ab2eddb6
Android: Implement DW_DRAW_FULL flag for dw_draw_arc().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2535
diff
changeset
|
6244 // 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
|
6245 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
|
6246 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
|
6247 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
|
6248 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
|
6249 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
|
6250 |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
6251 if(x2 < x1) { |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
6252 left = x2.toFloat() |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
6253 right = x1.toFloat() |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
6254 } |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
6255 if(y2 < y1) { |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
6256 top = y2.toFloat() |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
6257 bottom = y1.toFloat() |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
6258 } |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
6259 |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
6260 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
|
6261 } else { |
2576
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
6262 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
|
6263 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
|
6264 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
|
6265 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
|
6266 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
|
6267 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
|
6268 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
|
6269 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
|
6270 |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
6271 // Convert to degrees |
db097ec28c90
Android: Fix drawArc() FULL option and refactor to reduce calculations.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2575
diff
changeset
|
6272 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
|
6273 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
|
6274 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
|
6275 |
2536
d172ab2eddb6
Android: Implement DW_DRAW_FULL flag for dw_draw_arc().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2535
diff
changeset
|
6276 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
|
6277 } |
2535
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6278 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6279 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6280 } |
d862d9e4069b
Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2531
diff
changeset
|
6281 |
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
|
6282 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
|
6283 { |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
6284 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
|
6285 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
|
6286 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
|
6287 |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
6288 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
|
6289 } |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
6290 |
473eb9ff3f04
Android: Implement dw_container_set_stripe() and center the images in the rows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2579
diff
changeset
|
6291 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
|
6292 { |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6293 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
|
6294 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
|
6295 if(bgColor != -1L) { |
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
6296 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
|
6297 } else { |
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
6298 this.bgcolor = null |
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
6299 } |
2531
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6300 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6301 } |
f45ebd96ebe5
Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2530
diff
changeset
|
6302 |
2490
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
6303 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
|
6304 { |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
6305 // creating timer task, timer |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
6306 val t = Timer() |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
6307 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
|
6308 override fun run() { |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
6309 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
|
6310 t.cancel() |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
6311 } |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
6312 } |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
6313 } |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
6314 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
|
6315 return t |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
6316 } |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
6317 |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
6318 fun timerDisconnect(timer: Timer) |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
6319 { |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
6320 timer.cancel() |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
6321 } |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
6322 |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
6323 fun doBeep(duration: Int) |
62e124eecd82
Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2489
diff
changeset
|
6324 { |
2491
bf4fe6bb512b
Android: Fix the permission error on the beep...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2490
diff
changeset
|
6325 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
|
6326 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
|
6327 val handler = Handler(Looper.getMainLooper()) |
bf4fe6bb512b
Android: Fix the permission error on the beep...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2490
diff
changeset
|
6328 handler.postDelayed({ |
bf4fe6bb512b
Android: Fix the permission error on the beep...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2490
diff
changeset
|
6329 toneGen.release() |
bf4fe6bb512b
Android: Fix the permission error on the beep...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2490
diff
changeset
|
6330 }, (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
|
6331 } |
666af45f33b5
Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2487
diff
changeset
|
6332 |
2482
4888503c3e3e
Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2481
diff
changeset
|
6333 fun debugMessage(text: String) |
4888503c3e3e
Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2481
diff
changeset
|
6334 { |
2690
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
6335 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
|
6336 } |
4888503c3e3e
Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2481
diff
changeset
|
6337 |
2788
8a4f162810c2
Android: During dw_file_browse() request read/write access to external
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2785
diff
changeset
|
6338 @Deprecated("Deprecated in Java") |
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
|
6339 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
|
6340 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
|
6341 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
|
6342 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
|
6343 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
|
6344 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
|
6345 } 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
|
6346 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
|
6347 } |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
6348 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
|
6349 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
|
6350 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
6351 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
6352 |
2715
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6353 fun getDataColumn(context: Context, uri: Uri?, selection: String?, selectionArgs: Array<String?>?): String? { |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6354 var cursor: Cursor? = null |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6355 val column = "_data" |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6356 val projection = arrayOf(column) |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6357 |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6358 try { |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6359 cursor = context.contentResolver.query( |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6360 uri!!, projection, selection, selectionArgs, |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6361 null |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6362 ) |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6363 if (cursor != null && cursor.moveToFirst()) { |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6364 val index = cursor.getColumnIndexOrThrow(column) |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6365 return cursor.getString(index) |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6366 } |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6367 } finally { |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6368 cursor?.close() |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6369 } |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6370 return null |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6371 } |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6372 |
2790
20d39af27aa4
Android: Add a new function for Android dw_file_open() which will open the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2789
diff
changeset
|
6373 fun fileOpen(filename: String, mode: Int): Int |
20d39af27aa4
Android: Add a new function for Android dw_file_open() which will open the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2789
diff
changeset
|
6374 { |
20d39af27aa4
Android: Add a new function for Android dw_file_open() which will open the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2789
diff
changeset
|
6375 var retval: Int = -1 |
20d39af27aa4
Android: Add a new function for Android dw_file_open() which will open the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2789
diff
changeset
|
6376 var uri = Uri.parse(filename) |
20d39af27aa4
Android: Add a new function for Android dw_file_open() which will open the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2789
diff
changeset
|
6377 var smode: String = "r" |
20d39af27aa4
Android: Add a new function for Android dw_file_open() which will open the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2789
diff
changeset
|
6378 var fd: ParcelFileDescriptor? = null |
20d39af27aa4
Android: Add a new function for Android dw_file_open() which will open the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2789
diff
changeset
|
6379 |
20d39af27aa4
Android: Add a new function for Android dw_file_open() which will open the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2789
diff
changeset
|
6380 if((mode and OsConstants.O_WRONLY) == OsConstants.O_WRONLY) { |
20d39af27aa4
Android: Add a new function for Android dw_file_open() which will open the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2789
diff
changeset
|
6381 smode = "w" |
20d39af27aa4
Android: Add a new function for Android dw_file_open() which will open the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2789
diff
changeset
|
6382 } else if((mode and OsConstants.O_RDWR) == OsConstants.O_RDWR) { |
20d39af27aa4
Android: Add a new function for Android dw_file_open() which will open the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2789
diff
changeset
|
6383 smode = "rw" |
20d39af27aa4
Android: Add a new function for Android dw_file_open() which will open the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2789
diff
changeset
|
6384 } |
20d39af27aa4
Android: Add a new function for Android dw_file_open() which will open the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2789
diff
changeset
|
6385 try { |
20d39af27aa4
Android: Add a new function for Android dw_file_open() which will open the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2789
diff
changeset
|
6386 fd = contentResolver.openFileDescriptor(uri, smode) |
20d39af27aa4
Android: Add a new function for Android dw_file_open() which will open the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2789
diff
changeset
|
6387 } catch (e: FileNotFoundException) { |
20d39af27aa4
Android: Add a new function for Android dw_file_open() which will open the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2789
diff
changeset
|
6388 fd = null |
20d39af27aa4
Android: Add a new function for Android dw_file_open() which will open the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2789
diff
changeset
|
6389 } |
20d39af27aa4
Android: Add a new function for Android dw_file_open() which will open the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2789
diff
changeset
|
6390 if (fd != null) { |
20d39af27aa4
Android: Add a new function for Android dw_file_open() which will open the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2789
diff
changeset
|
6391 retval = fd.fd |
20d39af27aa4
Android: Add a new function for Android dw_file_open() which will open the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2789
diff
changeset
|
6392 } |
20d39af27aa4
Android: Add a new function for Android dw_file_open() which will open the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2789
diff
changeset
|
6393 return retval |
20d39af27aa4
Android: Add a new function for Android dw_file_open() which will open the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2789
diff
changeset
|
6394 } |
20d39af27aa4
Android: Add a new function for Android dw_file_open() which will open the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2789
diff
changeset
|
6395 |
2715
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6396 // Defpath does not seem to be supported on Android using the ACTION_GET_CONTENT Intent |
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
|
6397 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
|
6398 { |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
6399 var retval: String? = null |
2788
8a4f162810c2
Android: During dw_file_browse() request read/write access to external
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2785
diff
changeset
|
6400 var permission = Manifest.permission.WRITE_EXTERNAL_STORAGE |
8a4f162810c2
Android: During dw_file_browse() request read/write access to external
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2785
diff
changeset
|
6401 var permissions: Int = -1 |
8a4f162810c2
Android: During dw_file_browse() request read/write access to external
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2785
diff
changeset
|
6402 |
8a4f162810c2
Android: During dw_file_browse() request read/write access to external
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2785
diff
changeset
|
6403 // Handle requesting permissions if necessary |
8a4f162810c2
Android: During dw_file_browse() request read/write access to external
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2785
diff
changeset
|
6404 permissions = ContextCompat.checkSelfPermission(this, permission) |
8a4f162810c2
Android: During dw_file_browse() request read/write access to external
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2785
diff
changeset
|
6405 if(permissions == -1) //PERMISSION_DENIED |
8a4f162810c2
Android: During dw_file_browse() request read/write access to external
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2785
diff
changeset
|
6406 { |
8a4f162810c2
Android: During dw_file_browse() request read/write access to external
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2785
diff
changeset
|
6407 // You can directly ask for the permission. |
8a4f162810c2
Android: During dw_file_browse() request read/write access to external
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2785
diff
changeset
|
6408 requestPermissions(arrayOf(permission), 100) |
8a4f162810c2
Android: During dw_file_browse() request read/write access to external
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2785
diff
changeset
|
6409 } |
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
|
6410 |
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
|
6411 // 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
|
6412 if(Looper.getMainLooper() != Looper.myLooper()) { |
2715
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6413 var success = true |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6414 |
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
|
6415 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
|
6416 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
|
6417 val fileintent = Intent(Intent.ACTION_GET_CONTENT) |
2715
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6418 // TODO: Filtering requires MIME types, not extensions |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6419 fileintent.type = "*/*" |
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
|
6420 fileintent.addCategory(Intent.CATEGORY_OPENABLE) |
2715
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6421 try { |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6422 startActivityForResult(fileintent, 100) |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6423 } catch (e: ActivityNotFoundException) { |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6424 success = false |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6425 } |
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
|
6426 } |
6b5057dd6b8e
Android: Experimental change for the new file browser... require it be on secondary...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2594
diff
changeset
|
6427 |
2715
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6428 if(success) { |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6429 // Wait until the intent finishes. |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6430 fileCond.await() |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6431 fileLock.unlock() |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6432 |
2790
20d39af27aa4
Android: Add a new function for Android dw_file_open() which will open the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2789
diff
changeset
|
6433 // Save the URI string for later use |
2795
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6434 retval = fileURI.toString() |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6435 |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6436 // If DW_DIRECTORY_OPEN or DW_FILE_PATH ... use the path not URI |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6437 if((flags and 65535) == 2 || ((flags shr 16) and 1) == 1) { |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6438 if (DocumentsContract.isDocumentUri(this, fileURI)) { |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6439 // ExternalStorageProvider |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6440 if (fileURI?.authority == "com.android.externalstorage.documents") { |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6441 val docId = DocumentsContract.getDocumentId(fileURI) |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6442 val split = docId.split(":").toTypedArray() |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6443 retval = Environment.getExternalStorageDirectory() |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6444 .toString() + "/" + split[1] |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6445 } else if (fileURI?.authority == "com.android.providers.downloads.documents") { |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6446 val id = DocumentsContract.getDocumentId(fileURI) |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6447 val contentUri = ContentUris.withAppendedId( |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6448 Uri.parse("content://downloads/public_downloads"), |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6449 java.lang.Long.valueOf(id) |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6450 ) |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6451 retval = getDataColumn(this, contentUri, null, null) |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6452 } else if (fileURI?.authority == "com.android.providers.media.documents") { |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6453 val docId = DocumentsContract.getDocumentId(fileURI) |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6454 val split = docId.split(":").toTypedArray() |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6455 val type = split[0] |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6456 var contentUri: Uri? = null |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6457 if ("image" == type) { |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6458 contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6459 } else if ("video" == type) { |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6460 contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6461 } else if ("audio" == type) { |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6462 contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6463 } |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6464 val selection = "_id=?" |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6465 val selectionArgs = arrayOf<String?>( |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6466 split[1] |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6467 ) |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6468 retval = getDataColumn(this, contentUri, selection, selectionArgs) |
2715
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6469 } |
2795
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6470 } else if (fileURI?.scheme == "content") { |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6471 retval = getDataColumn(this, fileURI, null, null) |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6472 } |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6473 // File |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6474 else if (fileURI?.scheme == "file") { |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6475 retval = fileURI?.path |
2715
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6476 } |
2795
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6477 |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6478 // If we are opening a directory DW_DIRECTORY_OPEN |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6479 if (retval != null && (flags and 65535) == 2) { |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6480 val split = retval.split("/") |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6481 val filename = split.last() |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6482 |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6483 if (filename != null) { |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6484 val pathlen = retval.length |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6485 val filelen = filename.length |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6486 |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6487 retval = retval.substring(0, pathlen - filelen - 1) |
5c61aba17b69
Android: Change dw_file_browse() to return URIs or paths on Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2790
diff
changeset
|
6488 } |
2715
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6489 } |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6490 } |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6491 } else { |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6492 // If we failed to start the intent... use old dialog |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6493 fileLock.unlock() |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6494 retval = fileBrowse(title, defpath, ext, flags) |
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
|
6495 } |
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
|
6496 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
6497 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
|
6498 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
6499 |
2526
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
6500 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
|
6501 { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
6502 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
|
6503 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
6504 waitOnUiThread { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
6505 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
|
6506 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
|
6507 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
|
6508 // 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
|
6509 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
|
6510 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
|
6511 } |
2c15b3d41fe4
Android: Add preliminary new file browser that uses the system ACTION_GET_CONTENT Intent.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2590
diff
changeset
|
6512 }) |
2526
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
6513 if(ext != null) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
6514 fc.setExtension(ext) |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
6515 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
6516 fc.showDialog() |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
6517 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
6518 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
6519 // 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
|
6520 try { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
6521 Looper.loop() |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
6522 } catch (e2: RuntimeException) { |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
6523 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
6524 |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
6525 return retval |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
6526 } |
d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2524
diff
changeset
|
6527 |
2735
970cbcdb68f9
Android: This is kind of a hacky solution, but use a while loop to figure out...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2734
diff
changeset
|
6528 // No reverse evaluate function to get the offset from a color in a range... |
970cbcdb68f9
Android: This is kind of a hacky solution, but use a while loop to figure out...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2734
diff
changeset
|
6529 // So we do a hacky while loop to test offsets in the range to see if we can |
970cbcdb68f9
Android: This is kind of a hacky solution, but use a while loop to figure out...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2734
diff
changeset
|
6530 // find the color and return the offset... return -1F on failure |
970cbcdb68f9
Android: This is kind of a hacky solution, but use a while loop to figure out...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2734
diff
changeset
|
6531 fun colorSliderOffset(chosenColor: Int, startColor: Int, endColor: Int): Float |
970cbcdb68f9
Android: This is kind of a hacky solution, but use a while loop to figure out...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2734
diff
changeset
|
6532 { |
970cbcdb68f9
Android: This is kind of a hacky solution, but use a while loop to figure out...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2734
diff
changeset
|
6533 val argbEvaluator = android.animation.ArgbEvaluator() |
970cbcdb68f9
Android: This is kind of a hacky solution, but use a while loop to figure out...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2734
diff
changeset
|
6534 var testOffset = 0F |
970cbcdb68f9
Android: This is kind of a hacky solution, but use a while loop to figure out...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2734
diff
changeset
|
6535 |
970cbcdb68f9
Android: This is kind of a hacky solution, but use a while loop to figure out...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2734
diff
changeset
|
6536 while(testOffset <= 1F) { |
970cbcdb68f9
Android: This is kind of a hacky solution, but use a while loop to figure out...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2734
diff
changeset
|
6537 val testColor = argbEvaluator.evaluate(testOffset, startColor, endColor) as Int |
970cbcdb68f9
Android: This is kind of a hacky solution, but use a while loop to figure out...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2734
diff
changeset
|
6538 |
970cbcdb68f9
Android: This is kind of a hacky solution, but use a while loop to figure out...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2734
diff
changeset
|
6539 if(testColor == chosenColor) { |
970cbcdb68f9
Android: This is kind of a hacky solution, but use a while loop to figure out...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2734
diff
changeset
|
6540 return testOffset |
970cbcdb68f9
Android: This is kind of a hacky solution, but use a while loop to figure out...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2734
diff
changeset
|
6541 } |
970cbcdb68f9
Android: This is kind of a hacky solution, but use a while loop to figure out...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2734
diff
changeset
|
6542 testOffset += 0.001F |
970cbcdb68f9
Android: This is kind of a hacky solution, but use a while loop to figure out...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2734
diff
changeset
|
6543 } |
970cbcdb68f9
Android: This is kind of a hacky solution, but use a while loop to figure out...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2734
diff
changeset
|
6544 return -1F |
970cbcdb68f9
Android: This is kind of a hacky solution, but use a while loop to figure out...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2734
diff
changeset
|
6545 } |
970cbcdb68f9
Android: This is kind of a hacky solution, but use a while loop to figure out...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2734
diff
changeset
|
6546 |
2714
26bb1e4a97d0
Android: Add glue to bring up the color wheel when calling dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2713
diff
changeset
|
6547 fun colorChoose(color: Int, alpha: Int, red: Int, green: Int, blue: Int): Int |
26bb1e4a97d0
Android: Add glue to bring up the color wheel when calling dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2713
diff
changeset
|
6548 { |
2715
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6549 var retval: Int = color |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6550 |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6551 // This can't be called from the main thread |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6552 if(Looper.getMainLooper() != Looper.myLooper()) { |
2722
cacde852e2db
Android: Add dialog dismiss and color change handlers to the color chooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2720
diff
changeset
|
6553 colorLock.lock() |
2715
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6554 waitOnUiThread { |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6555 val dialog = Dialog(this) |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6556 val colorWheel = ColorWheel(this, null, 0) |
2733
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6557 val gradientBar = GradientSeekBar(this, null, 0) |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6558 val display = View(this) |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6559 val layout = RelativeLayout(this) |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6560 val w = RelativeLayout.LayoutParams.MATCH_PARENT |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6561 val h = RelativeLayout.LayoutParams.WRAP_CONTENT |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6562 val margin = 10 |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6563 |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6564 colorWheel.id = View.generateViewId() |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6565 gradientBar.id = View.generateViewId() |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6566 display.id = View.generateViewId() |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6567 gradientBar.orientation = GradientSeekBar.Orientation.HORIZONTAL |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6568 |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6569 var params: RelativeLayout.LayoutParams = RelativeLayout.LayoutParams(w, 100) |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6570 params.addRule(RelativeLayout.ALIGN_PARENT_TOP) |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6571 params.setMargins(margin,margin,margin,margin) |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6572 layout.addView(display, params) |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6573 params = RelativeLayout.LayoutParams(w, w) |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6574 params.setMargins(margin,margin,margin,margin) |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6575 params.addRule(RelativeLayout.BELOW, display.id) |
2734
cd3c7740e352
Android: Attempt at some Color Chooser improvements... Fix layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2733
diff
changeset
|
6576 params.addRule(RelativeLayout.ABOVE, gradientBar.id) |
2733
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6577 layout.addView(colorWheel, params) |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6578 params = RelativeLayout.LayoutParams(w, h) |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6579 params.setMargins(margin,margin,margin,margin) |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6580 params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM) |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6581 layout.addView(gradientBar, params) |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6582 |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6583 dialog.setContentView(layout) |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6584 colorChosen = Color.rgb(red, green, blue) |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6585 colorWheel.rgb = colorChosen |
2734
cd3c7740e352
Android: Attempt at some Color Chooser improvements... Fix layout.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2733
diff
changeset
|
6586 gradientBar.setBlackToColor(colorWheel.rgb) |
2735
970cbcdb68f9
Android: This is kind of a hacky solution, but use a while loop to figure out...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2734
diff
changeset
|
6587 val testOffset = colorSliderOffset(colorChosen, gradientBar.startColor, gradientBar.endColor) |
970cbcdb68f9
Android: This is kind of a hacky solution, but use a while loop to figure out...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2734
diff
changeset
|
6588 if(testOffset < 0F) { |
970cbcdb68f9
Android: This is kind of a hacky solution, but use a while loop to figure out...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2734
diff
changeset
|
6589 // If our test method didn't work... convert to HSV |
970cbcdb68f9
Android: This is kind of a hacky solution, but use a while loop to figure out...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2734
diff
changeset
|
6590 // and use the brightness value as the slider offset |
970cbcdb68f9
Android: This is kind of a hacky solution, but use a while loop to figure out...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2734
diff
changeset
|
6591 var hsv = FloatArray(3) |
970cbcdb68f9
Android: This is kind of a hacky solution, but use a while loop to figure out...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2734
diff
changeset
|
6592 Color.colorToHSV(colorChosen, hsv) |
970cbcdb68f9
Android: This is kind of a hacky solution, but use a while loop to figure out...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2734
diff
changeset
|
6593 gradientBar.offset = hsv[2] |
970cbcdb68f9
Android: This is kind of a hacky solution, but use a while loop to figure out...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2734
diff
changeset
|
6594 } else { |
970cbcdb68f9
Android: This is kind of a hacky solution, but use a while loop to figure out...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2734
diff
changeset
|
6595 gradientBar.offset = testOffset |
970cbcdb68f9
Android: This is kind of a hacky solution, but use a while loop to figure out...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2734
diff
changeset
|
6596 } |
2733
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6597 display.setBackgroundColor(colorChosen) |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6598 colorWheel.colorChangeListener = { rgb: Int -> |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6599 gradientBar.setBlackToColor(rgb) |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6600 display.setBackgroundColor(gradientBar.argb) |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6601 colorChosen = gradientBar.argb |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6602 } |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6603 gradientBar.colorChangeListener = { offset: Float, argb: Int -> |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6604 display.setBackgroundColor(argb) |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6605 colorChosen = argb |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6606 } |
2715
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6607 dialog.window?.setLayout( |
2733
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6608 ViewGroup.LayoutParams.MATCH_PARENT, |
34e34d5d56e8
Android: Add a color picker preview area and a gradient slider for contrast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2727
diff
changeset
|
6609 ViewGroup.LayoutParams.MATCH_PARENT |
2715
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6610 ) |
2722
cacde852e2db
Android: Add dialog dismiss and color change handlers to the color chooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2720
diff
changeset
|
6611 dialog.setOnDismissListener { |
cacde852e2db
Android: Add dialog dismiss and color change handlers to the color chooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2720
diff
changeset
|
6612 colorLock.lock() |
cacde852e2db
Android: Add dialog dismiss and color change handlers to the color chooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2720
diff
changeset
|
6613 colorCond.signal() |
cacde852e2db
Android: Add dialog dismiss and color change handlers to the color chooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2720
diff
changeset
|
6614 colorLock.unlock() |
cacde852e2db
Android: Add dialog dismiss and color change handlers to the color chooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2720
diff
changeset
|
6615 } |
2715
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6616 dialog.show() |
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6617 } |
2722
cacde852e2db
Android: Add dialog dismiss and color change handlers to the color chooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2720
diff
changeset
|
6618 colorCond.await() |
cacde852e2db
Android: Add dialog dismiss and color change handlers to the color chooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2720
diff
changeset
|
6619 retval = colorChosen |
cacde852e2db
Android: Add dialog dismiss and color change handlers to the color chooser.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2720
diff
changeset
|
6620 colorLock.unlock() |
2714
26bb1e4a97d0
Android: Add glue to bring up the color wheel when calling dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2713
diff
changeset
|
6621 } |
26bb1e4a97d0
Android: Add glue to bring up the color wheel when calling dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2713
diff
changeset
|
6622 return retval |
26bb1e4a97d0
Android: Add glue to bring up the color wheel when calling dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2713
diff
changeset
|
6623 } |
26bb1e4a97d0
Android: Add glue to bring up the color wheel when calling dw_color_choose().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2713
diff
changeset
|
6624 |
2486
cec43818bd3e
Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2484
diff
changeset
|
6625 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
|
6626 { |
2579
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
6627 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
|
6628 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
6629 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
6630 // 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
|
6631 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
|
6632 |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
6633 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
|
6634 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
|
6635 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
|
6636 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
|
6637 ) |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
6638 //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
|
6639 { _: DialogInterface, _: Int -> |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
6640 retval = 1 |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
6641 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
|
6642 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
6643 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
6644 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
|
6645 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
|
6646 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
|
6647 ) { _: DialogInterface, _: Int -> |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
6648 retval = 0 |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
6649 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
|
6650 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
6651 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
6652 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
|
6653 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
|
6654 ) |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
6655 //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
|
6656 { _: DialogInterface, _: Int -> |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
6657 retval = 0 |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
6658 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
|
6659 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
6660 } |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
6661 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
|
6662 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
|
6663 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
|
6664 ) { _: DialogInterface, _: Int -> |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
6665 retval = 2 |
68ee9a89e0f0
Android: Code cleanup, fix all warnings except for unused function/parameters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2578
diff
changeset
|
6666 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
|
6667 } |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
6668 } |
2573
ea75e295025b
Android: Make message boxes modal (not cancelable).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2572
diff
changeset
|
6669 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
|
6670 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
|
6671 |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
6672 // 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
|
6673 try { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
6674 Looper.loop() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
6675 } 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
|
6676 } |
2486
cec43818bd3e
Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2484
diff
changeset
|
6677 } |
cec43818bd3e
Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2484
diff
changeset
|
6678 return retval |
cec43818bd3e
Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2484
diff
changeset
|
6679 } |
cec43818bd3e
Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2484
diff
changeset
|
6680 |
2530
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
6681 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
|
6682 { |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
6683 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
|
6684 return true |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
6685 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
6686 return false |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
6687 } |
b9923432cb1f
Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2529
diff
changeset
|
6688 |
2514
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
6689 fun mainSleep(milliseconds: Int) |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
6690 { |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
6691 // 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
|
6692 // 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
|
6693 // 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
|
6694 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
|
6695 val starttime = System.currentTimeMillis() |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
6696 |
2637
22105f99dd6a
Android: Add support for transparent background color for text drawing.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2620
diff
changeset
|
6697 // 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
|
6698 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
|
6699 var thrown: Boolean = false |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
6700 |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
6701 override fun queueIdle(): Boolean { |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
6702 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
|
6703 if (thrown == false) { |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
6704 thrown = true |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
6705 throw java.lang.RuntimeException() |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
6706 } |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
6707 return false |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
6708 } |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
6709 return true |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
6710 } |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
6711 }) |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
6712 |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
6713 // 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
|
6714 try { |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
6715 Looper.loop() |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
6716 } catch (e2: RuntimeException) { |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
6717 } |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
6718 } |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
6719 else |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
6720 { |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
6721 // 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
|
6722 Thread.sleep(milliseconds.toLong()) |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
6723 } |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
6724 } |
5f711e86a211
Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2510
diff
changeset
|
6725 |
2487
83f8f4f58a98
Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2486
diff
changeset
|
6726 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
|
6727 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
6728 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
6729 this.finishAffinity() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
6730 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
|
6731 } |
2494
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
6732 } |
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
6733 |
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
6734 fun dwindowsShutdown() |
b3e28eed0e50
Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2493
diff
changeset
|
6735 { |
2502
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
6736 waitOnUiThread { |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
6737 this.finishAffinity() |
b6319aed3298
Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2501
diff
changeset
|
6738 } |
2487
83f8f4f58a98
Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2486
diff
changeset
|
6739 } |
83f8f4f58a98
Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2486
diff
changeset
|
6740 |
2542
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
6741 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
|
6742 { |
2690
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
6743 appID = appid |
755d9ad07aaf
Android: Fix state exception by calling notifyDataSetChanged() on DWListBox.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2689
diff
changeset
|
6744 |
2522
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6745 waitOnUiThread { |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6746 // 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
|
6747 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
|
6748 // Create the NotificationChannel |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6749 val importance = NotificationManager.IMPORTANCE_DEFAULT |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6750 val mChannel = NotificationChannel(appid, appname, importance) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6751 // 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
|
6752 // or other notification behaviors after this |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6753 val notificationManager = |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6754 getSystemService(NOTIFICATION_SERVICE) as NotificationManager |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6755 notificationManager.createNotificationChannel(mChannel) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6756 } |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6757 } |
2542
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
6758 return Build.VERSION.SDK_INT |
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
6759 } |
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
6760 |
2543
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
6761 fun dwMain() |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
6762 { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
6763 runOnUiThread { |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
6764 // 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
|
6765 invalidateOptionsMenu() |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
6766 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
6767 } |
f9367eb9a6e7
Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2542
diff
changeset
|
6768 |
2542
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
6769 fun androidGetRelease(): String |
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
6770 { |
bb75e64e6138
Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2539
diff
changeset
|
6771 return Build.VERSION.RELEASE |
2522
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6772 } |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6773 |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6774 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
|
6775 { |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6776 var builder: NotificationCompat.Builder? = null |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6777 |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6778 waitOnUiThread { |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6779 builder = NotificationCompat.Builder(this, appid) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6780 .setContentTitle(title) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6781 .setContentText(text) |
2715
e9ad53d2271b
Android: Fix Intent based file chooser and switch to using it by default.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2714
diff
changeset
|
6782 .setSmallIcon(R.mipmap.sym_def_app_icon) |
2522
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6783 .setPriority(NotificationCompat.PRIORITY_DEFAULT) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6784 } |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6785 return builder |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6786 } |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6787 |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6788 fun notificationSend(builder: NotificationCompat.Builder) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6789 { |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6790 waitOnUiThread { |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6791 notificationID += 1 |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6792 with(NotificationManagerCompat.from(this)) { |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6793 // 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
|
6794 notify(notificationID, builder.build()) |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6795 } |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6796 } |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6797 } |
66c490aa719d
Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2521
diff
changeset
|
6798 |
2475
16d195d46f2a
Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2474
diff
changeset
|
6799 /* |
2474
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
6800 * 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
|
6801 * 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
|
6802 */ |
2658
ad6fc7f1a9af
Android: Asset/Resource refactoring for compatibility with other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2656
diff
changeset
|
6803 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
|
6804 external fun eventHandler( |
2499
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
6805 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
|
6806 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
|
6807 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
|
6808 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
|
6809 str2: String?, |
2499
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
6810 inta: Int, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
6811 intb: Int, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
6812 intc: Int, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
6813 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
|
6814 ): Int |
2499
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
6815 external fun eventHandlerInt( |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
6816 obj1: View, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
6817 message: Int, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
6818 inta: Int, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
6819 intb: Int, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
6820 intc: Int, |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
6821 intd: Int |
ff3310fa6d72
Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2498
diff
changeset
|
6822 ) |
2483
9f7af6d8c6a4
Android: Fix signal handlers so they actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2482
diff
changeset
|
6823 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
|
6824 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
|
6825 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
|
6826 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
|
6827 external fun eventHandlerContainer(obj1: View, message: Int, title: String?, x: Int, y: Int, data: Long) |
2785
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
6828 external fun eventHandlerTree(obj1: View, message: Int, item: DWTreeItem?, title: String?, data: Long) |
220d63da2183
Android: Implement ITEM_CONTEXT, ITEM_SELECT and TREE_EXPAND callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2784
diff
changeset
|
6829 external fun eventHandlerTreeItem(obj1: View, message: Int, item: DWTreeItem?) |
2596
60ec91d23746
Android: Add initial keyboard support for Android.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2595
diff
changeset
|
6830 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
|
6831 |
2474
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
6832 companion object |
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
6833 { |
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6834 // 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
|
6835 init |
a13e6db064f4
Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
2473
diff
changeset
|
6836 { |
2473
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6837 System.loadLibrary("dwindows") |
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6838 } |
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6839 } |
aa420e366b2b
Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff
changeset
|
6840 } |