Mercurial > dwindows
comparison android/DWindows.kt @ 2477:3fbf8783122d
Android: First functional version. Notebook-less first page of dwtest works.
FindClass failed on any created threads.. using a modified version of this:
https://stackoverflow.com/questions/13263340/findclass-from-any-thread-in-android-jni
Implemented dw_box_unpack(). Had to do this to fix an exception when
repacking a widget in dwtest's archive_add().
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 22 Apr 2021 17:49:20 +0000 |
parents | 20c9e83cba2a |
children | b0230e378667 |
comparison
equal
deleted
inserted
replaced
2476:20c9e83cba2a | 2477:3fbf8783122d |
---|---|
7 import androidx.appcompat.app.AppCompatActivity | 7 import androidx.appcompat.app.AppCompatActivity |
8 | 8 |
9 | 9 |
10 class DWindows : AppCompatActivity() | 10 class DWindows : AppCompatActivity() |
11 { | 11 { |
12 public var windowLayout: LinearLayout = LinearLayout(this) | |
13 | |
14 override fun onCreate(savedInstanceState: Bundle?) | 12 override fun onCreate(savedInstanceState: Bundle?) |
15 { | 13 { |
16 super.onCreate(savedInstanceState) | 14 super.onCreate(savedInstanceState) |
17 setContentView(windowLayout) | |
18 | 15 |
19 val m = packageManager | 16 val m = packageManager |
20 var s = packageName | 17 var s = packageName |
21 val p = m.getPackageInfo(s!!, 0) | 18 val p = m.getPackageInfo(s!!, 0) |
22 s = p.applicationInfo.dataDir | 19 s = p.applicationInfo.dataDir |
29 * These are the Android calls to actually create the UI... | 26 * These are the Android calls to actually create the UI... |
30 * forwarded from the C Dynamic Windows API | 27 * forwarded from the C Dynamic Windows API |
31 */ | 28 */ |
32 fun windowNew(title: String, style: Int): LinearLayout | 29 fun windowNew(title: String, style: Int): LinearLayout |
33 { | 30 { |
31 var windowLayout: LinearLayout = LinearLayout(this) | |
32 setContentView(windowLayout) | |
34 // For now we just return our DWindows' main activity layout... | 33 // For now we just return our DWindows' main activity layout... |
35 // in the future, later calls should create new activities | 34 // in the future, later calls should create new activities |
36 return windowLayout | 35 return windowLayout |
37 } | 36 } |
38 | 37 |
64 } else if(h < 1) { | 63 } else if(h < 1) { |
65 h = LinearLayout.LayoutParams.WRAP_CONTENT | 64 h = LinearLayout.LayoutParams.WRAP_CONTENT |
66 } | 65 } |
67 item.layoutParams = LinearLayout.LayoutParams(w, h) | 66 item.layoutParams = LinearLayout.LayoutParams(w, h) |
68 box.addView(item) | 67 box.addView(item) |
68 } | |
69 | |
70 fun boxUnpack(item: View) | |
71 { | |
72 var box: LinearLayout = item.parent as LinearLayout | |
73 box.removeView(item) | |
69 } | 74 } |
70 | 75 |
71 fun buttonNew(text: String, cid: Int): Button | 76 fun buttonNew(text: String, cid: Int): Button |
72 { | 77 { |
73 val button = Button(this) | 78 val button = Button(this) |