diff android/dw.cpp @ 2834:0cbe8201db3c

Android: Initial implementation of DW_CONTAINER_MODE_EXTRA/MULTI. The layout diverges slightly from the iOS implementation for the sake of implementation simplicity. Will unify the two looks in upcoming commits. Still need to implement DW_SIGNAL_COLUMN_CLICKED.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 12 Sep 2022 10:13:24 +0000
parents 469e5748c8a5
children 1f0017a07771
line wrap: on
line diff
--- a/android/dw.cpp	Sun Sep 11 12:43:08 2022 +0000
+++ b/android/dw.cpp	Mon Sep 12 10:13:24 2022 +0000
@@ -44,6 +44,7 @@
 static char _dw_exec_dir[MAX_PATH+1] = {0};
 static char _dw_user_dir[MAX_PATH+1] = {0};
 static int _dw_android_api = 0;
+static int _dw_container_mode = DW_CONTAINER_MODE_DEFAULT;
 
 static pthread_key_t _dw_env_key;
 static pthread_key_t _dw_fgcolor_key;
@@ -8081,6 +8082,8 @@
         case DW_FEATURE_CONTAINER_STRIPE:        /* Supports striped line display in container widgets */
         case DW_FEATURE_TREE:                    /* Supports the Tree Widget */
             return DW_FEATURE_ENABLED;
+        case DW_FEATURE_CONTAINER_MODE:          /* Supports alternate container view modes */
+            return _dw_container_mode;
         case DW_FEATURE_DARK_MODE:               /* Supports Dark Mode user interface */
         {
             /* Dark Mode on Android requires Android 10 (API 29) */
@@ -8121,6 +8124,28 @@
         case DW_FEATURE_TREE:                    /* Supports the Tree Widget */
             return DW_ERROR_GENERAL;
         /* These features are supported and configurable */
+        case DW_FEATURE_CONTAINER_MODE:          /* Supports alternate container view modes */
+        {
+            if(state >= DW_CONTAINER_MODE_DEFAULT && state < DW_CONTAINER_MODE_MAX)
+            {
+                JNIEnv *env;
+
+                if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
+                {
+                    // First get the class that contains the method you need to call
+                    jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
+                    // Get the method that you want to call
+                    jmethodID setContainerMode = env->GetMethodID(clazz, "setContainerMode",
+                                                                  "(I)V");
+                    _dw_container_mode = state;
+                    // Call the method on the object
+                    env->CallVoidMethod(_dw_obj, setContainerMode, (jint)state);
+                    _dw_jni_check_exception(env);
+                }
+                return DW_ERROR_NONE;
+            }
+            return DW_ERROR_GENERAL;
+        }
         case DW_FEATURE_DARK_MODE:               /* Supports Dark Mode user interface */
         {
             /* Dark Mode on Android requires 10 (API 29) */