Mercurial > dwindows
diff android/dw.cpp @ 2526:d3f09b3f3703
Android: Initial dw_file_browse() implementation, still needs some work.
Fix minor issues with the Calendar control.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 10 May 2021 02:01:28 +0000 |
parents | 9fd26efff9da |
children | 03f6870bcfcc |
line wrap: on
line diff
--- a/android/dw.cpp Sun May 09 22:39:13 2021 +0000 +++ b/android/dw.cpp Mon May 10 02:01:28 2021 +0000 @@ -760,6 +760,29 @@ */ char * API dw_file_browse(const char *title, const char *defpath, const char *ext, int flags) { + JNIEnv *env; + + if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) + { + // Use a long parameter + jstring jstr = env->NewStringUTF(title); + jstring path = NULL; + jstring jext = NULL; + if(defpath) + path = env->NewStringUTF(defpath); + if(ext) + jext = env->NewStringUTF(defpath); + // First get the class that contains the method you need to call + //jclass clazz = _dw_find_class(env, DW_CLASS_NAME); + jclass clazz = env->FindClass(DW_CLASS_NAME); + // Get the method that you want to call + jmethodID fileBrowse = env->GetMethodID(clazz, "fileBrowse", + "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)Ljava/lang/String;"); + // Call the method on the object + jstring jresult = (jstring)env->CallObjectMethod(_dw_obj, fileBrowse, jstr, path, jext, flags); + if(jresult) + return strdup(env->GetStringUTFChars(jresult, 0)); + } return NULL; } @@ -3283,7 +3306,7 @@ // Convert to Unix time ts.tm_year = year - 1900; - ts.tm_mon = month; + ts.tm_mon = month - 1; ts.tm_mday = day; date = mktime(&ts); @@ -3325,7 +3348,7 @@ if(year) *year = ts.tm_year + 1900; if(month) - *month = ts.tm_mon; + *month = ts.tm_mon + 1; if(day) *day = ts.tm_mday; }