diff android/DWindows.kt @ 2670:e3a95940c18f

Android: Implement DW_FCF_CLOSEBUTTON and DW_FCF_TITLEBAR flags. Move the window destroy logic into the C code event handler... That way handling the DW_SIGNAL_DELETE can prevent the window closure. The application still can't be stopped from closing, but windows can.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 18 Oct 2021 00:09:57 +0000
parents 2ad924c6493d
children a7868380098f
line wrap: on
line diff
--- a/android/DWindows.kt	Sun Oct 17 20:14:51 2021 +0000
+++ b/android/DWindows.kt	Mon Oct 18 00:09:57 2021 +0000
@@ -974,8 +974,10 @@
             val adapter: DWTabViewPagerAdapter = windowLayout!!.adapter as DWTabViewPagerAdapter
             val index = windowLayout!!.currentItem
 
-            if (index > 0) {
-                windowDestroy(adapter.viewList[index])
+            // If the current window has a close button...
+            if (index > 0 && (windowStyles[index] and 1) == 1) {
+                // Send the DW_SIGNAL_DELETE to the event handler
+                eventHandlerSimple(adapter.viewList[index], DWEvent.DELETE)
             }
         }
     }
@@ -1147,6 +1149,9 @@
                 if (adapter.viewList.count() == 1) {
                     this.title = title
                     windowLayout!!.setCurrentItem(0, false)
+                    if((windowStyles[0] and 2) != 2) {
+                        supportActionBar?.hide()
+                    }
                 }
             }
         }
@@ -1424,12 +1429,18 @@
                 // So using RecyclerView.scrollToPosition() also
                 windowLayout!!.setCurrentItem(index, true)
 
+                // Hide or show the actionbar based on the titlebar flag
+                if((windowStyles[index] and 2) == 2) {
+                    supportActionBar?.show()
+                } else {
+                    supportActionBar?.hide()
+                }
                 // If the new view has a default item, focus it
                 if(windowDefault[index] != null) {
                     windowDefault[index]?.requestFocus()
                 }
                 // Add or remove a back button depending on the visible window
-                if(index > 0) {
+                if(index > 0 && (windowStyles[index] and 1) == 1) {
                     this.actionBar?.setDisplayHomeAsUpEnabled(true)
                 } else {
                     this.actionBar?.setDisplayHomeAsUpEnabled(false)