Mercurial > dwindows
comparison 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 |
comparison
equal
deleted
inserted
replaced
2525:9fd26efff9da | 2526:d3f09b3f3703 |
---|---|
758 * the file path on success. | 758 * the file path on success. |
759 * | 759 * |
760 */ | 760 */ |
761 char * API dw_file_browse(const char *title, const char *defpath, const char *ext, int flags) | 761 char * API dw_file_browse(const char *title, const char *defpath, const char *ext, int flags) |
762 { | 762 { |
763 JNIEnv *env; | |
764 | |
765 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) | |
766 { | |
767 // Use a long parameter | |
768 jstring jstr = env->NewStringUTF(title); | |
769 jstring path = NULL; | |
770 jstring jext = NULL; | |
771 if(defpath) | |
772 path = env->NewStringUTF(defpath); | |
773 if(ext) | |
774 jext = env->NewStringUTF(defpath); | |
775 // First get the class that contains the method you need to call | |
776 //jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | |
777 jclass clazz = env->FindClass(DW_CLASS_NAME); | |
778 // Get the method that you want to call | |
779 jmethodID fileBrowse = env->GetMethodID(clazz, "fileBrowse", | |
780 "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)Ljava/lang/String;"); | |
781 // Call the method on the object | |
782 jstring jresult = (jstring)env->CallObjectMethod(_dw_obj, fileBrowse, jstr, path, jext, flags); | |
783 if(jresult) | |
784 return strdup(env->GetStringUTFChars(jresult, 0)); | |
785 } | |
763 return NULL; | 786 return NULL; |
764 } | 787 } |
765 | 788 |
766 /* | 789 /* |
767 * Gets the contents of the default clipboard as text. | 790 * Gets the contents of the default clipboard as text. |
3281 time_t date; | 3304 time_t date; |
3282 struct tm ts = {0}; | 3305 struct tm ts = {0}; |
3283 | 3306 |
3284 // Convert to Unix time | 3307 // Convert to Unix time |
3285 ts.tm_year = year - 1900; | 3308 ts.tm_year = year - 1900; |
3286 ts.tm_mon = month; | 3309 ts.tm_mon = month - 1; |
3287 ts.tm_mday = day; | 3310 ts.tm_mday = day; |
3288 date = mktime(&ts); | 3311 date = mktime(&ts); |
3289 | 3312 |
3290 // First get the class that contains the method you need to call | 3313 // First get the class that contains the method you need to call |
3291 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 3314 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
3323 date = (time_t)env->CallLongMethod(_dw_obj, calendarGetDate, handle); | 3346 date = (time_t)env->CallLongMethod(_dw_obj, calendarGetDate, handle); |
3324 ts = *localtime(&date); | 3347 ts = *localtime(&date); |
3325 if(year) | 3348 if(year) |
3326 *year = ts.tm_year + 1900; | 3349 *year = ts.tm_year + 1900; |
3327 if(month) | 3350 if(month) |
3328 *month = ts.tm_mon; | 3351 *month = ts.tm_mon + 1; |
3329 if(day) | 3352 if(day) |
3330 *day = ts.tm_mday; | 3353 *day = ts.tm_mday; |
3331 } | 3354 } |
3332 } | 3355 } |
3333 | 3356 |