changeset 2708:3a7dcc0ae08b

Android: Implement dw_mle_search(). Also revert lowercase() change. Another system is telling me lowercase() is experimental.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 19 Nov 2021 18:48:41 +0000
parents a3f6ca621453
children 3cb5aa73dace
files android/DWindows.kt android/dw.cpp dw.h
diffstat 3 files changed, 41 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/android/DWindows.kt	Fri Nov 19 02:49:53 2021 +0000
+++ b/android/DWindows.kt	Fri Nov 19 18:48:41 2021 +0000
@@ -330,7 +330,7 @@
     // filter on file extension
     private var extension: String? = null
     fun setExtension(extension: String?) {
-        this.extension = extension?.lowercase(Locale.ROOT)
+        this.extension = extension?.toLowerCase(Locale.ROOT)
     }
 
     // file selection event handling
@@ -363,7 +363,7 @@
                         } else if (extension == null) {
                             true
                         } else {
-                            file.name.lowercase(Locale.ROOT).endsWith(extension!!)
+                            file.name.toLowerCase(Locale.ROOT).endsWith(extension!!)
                         }
                     } else {
                         false
@@ -2236,6 +2236,26 @@
         }
     }
 
+    fun mleSearch(mle: EditText, text: String, point: Int, flags: Int): Int
+    {
+        var retval: Int = -1
+        var ignorecase: Boolean = true
+
+        // DW_MLE_CASESENSITIVE 1
+        if(flags == 1) {
+            ignorecase = false
+        }
+
+        waitOnUiThread {
+            retval = mle.text.indexOf(text, point, ignorecase)
+
+            if(retval > -1) {
+                mle.setSelection(retval, retval + text.length)
+            }
+        }
+        return retval
+    }
+
     fun mleClear(mle: EditText)
     {
         waitOnUiThread {
--- a/android/dw.cpp	Fri Nov 19 02:49:53 2021 +0000
+++ b/android/dw.cpp	Fri Nov 19 18:48:41 2021 +0000
@@ -2803,7 +2803,24 @@
  */
 int API dw_mle_search(HWND handle, const char *text, int point, unsigned long flags)
 {
-    return DW_ERROR_UNKNOWN;
+    JNIEnv *env;
+    int retval = DW_ERROR_UNKNOWN;
+
+    if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
+    {
+        // Construct a String
+        jstring jstr = env->NewStringUTF(text);
+        // 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 mleSearch = env->GetMethodID(clazz, "mleSearch",
+                                               "(Landroid/widget/EditText;Ljava/lang/String;II)I");
+        // Call the method on the object
+        retval = env->CallIntMethod(_dw_obj, mleSearch, handle, jstr, point, (jint)flags);
+        if(_dw_jni_check_exception(env))
+            retval = DW_ERROR_UNKNOWN;
+    }
+    return retval;
 }
 
 /*
--- a/dw.h	Fri Nov 19 02:49:53 2021 +0000
+++ b/dw.h	Fri Nov 19 18:48:41 2021 +0000
@@ -854,7 +854,7 @@
 
 #define DW_LIT_NONE              -1
 
-#define DW_MLE_CASESENSITIVE    0
+#define DW_MLE_CASESENSITIVE     1
 
 #define DW_BS_NOBORDER           0