comparison android/dw.cpp @ 2551:127779860ac1

Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 15 May 2021 00:44:24 +0000
parents c4d75d30430c
children d2d8c66ad062
comparison
equal deleted inserted replaced
2550:a8d90e2896bc 2551:127779860ac1
587 return _dw_colors[thiscolor]; 587 return _dw_colors[thiscolor];
588 } 588 }
589 return 0; 589 return 0;
590 } 590 }
591 591
592 int _dw_dark_mode_detected()
593 {
594 JNIEnv *env;
595
596 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
597 {
598 // First get the class that contains the method you need to call
599 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
600 // Get the method that you want to call
601 jmethodID darkModeDetected = env->GetMethodID(clazz, "darkModeDetected",
602 "()I");
603 // Call the method on the object
604 return env->CallIntMethod(_dw_obj, darkModeDetected);
605 }
606 return DW_ERROR_UNKNOWN;
607 }
608
592 /* 609 /*
593 * Runs a message loop for Dynamic Windows. 610 * Runs a message loop for Dynamic Windows.
594 */ 611 */
595 void API dw_main(void) 612 void API dw_main(void)
596 { 613 {
4448 4465
4449 // First get the class that contains the method you need to call 4466 // First get the class that contains the method you need to call
4450 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); 4467 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
4451 // Get the method that you want to call 4468 // Get the method that you want to call
4452 jmethodID windowSetColor = env->GetMethodID(clazz, "windowSetColor", 4469 jmethodID windowSetColor = env->GetMethodID(clazz, "windowSetColor",
4453 "(Landroid/view/View;IIIIIIII)V"); 4470 "(Landroid/view/View;IIIIIIIIII)V");
4454 // Call the method on the object 4471 // Call the method on the object
4455 env->CallVoidMethod(_dw_obj, windowSetColor, handle, 4472 env->CallVoidMethod(_dw_obj, windowSetColor, handle,
4456 0, (jint)DW_RED_VALUE(_fore), (jint)DW_GREEN_VALUE(_fore), (jint)DW_BLUE_VALUE(_fore), 4473 (jint)fore, 0, (jint)DW_RED_VALUE(_fore), (jint)DW_GREEN_VALUE(_fore), (jint)DW_BLUE_VALUE(_fore),
4457 0, (jint)DW_RED_VALUE(_back), (jint)DW_GREEN_VALUE(_back), (jint)DW_BLUE_VALUE(_back)); 4474 (jint)back, 0, (jint)DW_RED_VALUE(_back), (jint)DW_GREEN_VALUE(_back), (jint)DW_BLUE_VALUE(_back));
4458 return DW_ERROR_NONE; 4475 return DW_ERROR_NONE;
4459 } 4476 }
4460 return DW_ERROR_GENERAL; 4477 return DW_ERROR_GENERAL;
4461 } 4478 }
4462 4479
6426 { 6443 {
6427 switch(feature) 6444 switch(feature)
6428 { 6445 {
6429 case DW_FEATURE_HTML: /* Supports the HTML Widget */ 6446 case DW_FEATURE_HTML: /* Supports the HTML Widget */
6430 case DW_FEATURE_HTML_RESULT: /* Supports the DW_SIGNAL_HTML_RESULT callback */ 6447 case DW_FEATURE_HTML_RESULT: /* Supports the DW_SIGNAL_HTML_RESULT callback */
6431 case DW_FEATURE_DARK_MODE: /* Supports Dark Mode user interface */
6432 case DW_FEATURE_NOTIFICATION: /* Supports sending system notifications */ 6448 case DW_FEATURE_NOTIFICATION: /* Supports sending system notifications */
6433 case DW_FEATURE_UTF8_UNICODE: /* Supports UTF8 encoded Unicode text */ 6449 case DW_FEATURE_UTF8_UNICODE: /* Supports UTF8 encoded Unicode text */
6434 case DW_FEATURE_MLE_WORD_WRAP: /* Supports word wrapping in Multi-line Edit boxes */ 6450 case DW_FEATURE_MLE_WORD_WRAP: /* Supports word wrapping in Multi-line Edit boxes */
6435 case DW_FEATURE_CONTAINER_STRIPE: /* Supports striped line display in container widgets */ 6451 case DW_FEATURE_CONTAINER_STRIPE: /* Supports striped line display in container widgets */
6436 return DW_FEATURE_ENABLED; 6452 return DW_FEATURE_ENABLED;
6453 case DW_FEATURE_DARK_MODE: /* Supports Dark Mode user interface */
6454 {
6455 /* Dark Mode on Android requires Android 10 (API 29) */
6456 if(_dw_android_api >= 29) {
6457 return _dw_dark_mode_detected();
6458 }
6459 return DW_FEATURE_UNSUPPORTED;
6460 }
6437 default: 6461 default:
6438 return DW_FEATURE_UNSUPPORTED; 6462 return DW_FEATURE_UNSUPPORTED;
6439 } 6463 }
6440 } 6464 }
6441 6465
6457 switch(feature) 6481 switch(feature)
6458 { 6482 {
6459 /* These features are supported but not configurable */ 6483 /* These features are supported but not configurable */
6460 case DW_FEATURE_HTML: /* Supports the HTML Widget */ 6484 case DW_FEATURE_HTML: /* Supports the HTML Widget */
6461 case DW_FEATURE_HTML_RESULT: /* Supports the DW_SIGNAL_HTML_RESULT callback */ 6485 case DW_FEATURE_HTML_RESULT: /* Supports the DW_SIGNAL_HTML_RESULT callback */
6462 case DW_FEATURE_DARK_MODE: /* Supports Dark Mode user interface */
6463 case DW_FEATURE_NOTIFICATION: /* Supports sending system notifications */ 6486 case DW_FEATURE_NOTIFICATION: /* Supports sending system notifications */
6464 case DW_FEATURE_UTF8_UNICODE: /* Supports UTF8 encoded Unicode text */ 6487 case DW_FEATURE_UTF8_UNICODE: /* Supports UTF8 encoded Unicode text */
6465 case DW_FEATURE_MLE_WORD_WRAP: /* Supports word wrapping in Multi-line Edit boxes */ 6488 case DW_FEATURE_MLE_WORD_WRAP: /* Supports word wrapping in Multi-line Edit boxes */
6466 case DW_FEATURE_CONTAINER_STRIPE: /* Supports striped line display in container widgets */ 6489 case DW_FEATURE_CONTAINER_STRIPE: /* Supports striped line display in container widgets */
6467 return DW_ERROR_GENERAL; 6490 return DW_ERROR_GENERAL;
6468 /* These features are supported and configurable */ 6491 /* These features are supported and configurable */
6492 case DW_FEATURE_DARK_MODE: /* Supports Dark Mode user interface */
6493 {
6494 /* Dark Mode on Android requires 10 (API 29) */
6495 if(_dw_android_api >= 29) {
6496 /* While technically configurable....
6497 * for now just return DW_ERROR_GENERAL
6498 */
6499 return DW_ERROR_GENERAL;
6500 }
6501 return DW_FEATURE_UNSUPPORTED;
6502 }
6469 default: 6503 default:
6470 return DW_FEATURE_UNSUPPORTED; 6504 return DW_FEATURE_UNSUPPORTED;
6471 } 6505 }
6472 } 6506 }
6473 6507