From 0ba1662f81bac36d1f494d64b6154032318348a0 Mon Sep 17 00:00:00 2001 From: Monte Goulding Date: Fri, 20 Mar 2020 21:25:32 +1100 Subject: [PATCH] [[ Bug 22607 ]] Implement system appearance support This patch implements a `systemAppearance` property and a `systemAppearanceChanged` message for macOS, Android and iOS. The property returns if the application is running under either light or dark mode. The message is sent to the current card of the defaultStack when the system appearance changes (either automatically or when the user changes it). --- .../message/systemAppearanceChanged.lcdoc | 35 +++++++++++++++++++ .../property/systemAppearance.lcdoc | 30 ++++++++++++++++ docs/notes/bugfix-22607.md | 7 ++++ engine/src/desktop-dc.cpp | 7 ++++ engine/src/desktop-dc.h | 4 ++- engine/src/desktop.cpp | 10 ++++++ engine/src/exec-interface2.cpp | 23 ++++++++++++ engine/src/exec.h | 2 ++ .../src/java/com/runrev/android/Engine.java | 33 ++++++++++++++++- engine/src/lextable.cpp | 3 +- engine/src/mac-core.mm | 25 ++++++++++++- engine/src/mblandroiddc.cpp | 18 ++++++++++ engine/src/mbldc.h | 2 ++ engine/src/mbliphoneapp.mm | 5 +++ engine/src/mbliphonedc.mm | 16 +++++++++ engine/src/mblnotification.cpp | 5 +++ engine/src/mblnotification.h | 1 + engine/src/mcstring.cpp | 3 ++ engine/src/mcstring.h | 2 ++ engine/src/parsedef.h | 2 ++ engine/src/platform-internal.h | 1 + engine/src/platform.cpp | 8 +++++ engine/src/platform.h | 8 +++++ engine/src/property.cpp | 3 ++ engine/src/uidc.cpp | 8 +++++ engine/src/uidc.h | 8 +++++ .../revsaveasandroidstandalone.livecodescript | 3 +- 27 files changed, 266 insertions(+), 6 deletions(-) create mode 100644 docs/dictionary/message/systemAppearanceChanged.lcdoc create mode 100644 docs/dictionary/property/systemAppearance.lcdoc create mode 100644 docs/notes/bugfix-22607.md diff --git a/docs/dictionary/message/systemAppearanceChanged.lcdoc b/docs/dictionary/message/systemAppearanceChanged.lcdoc new file mode 100644 index 00000000000..3d35b86bfbc --- /dev/null +++ b/docs/dictionary/message/systemAppearanceChanged.lcdoc @@ -0,0 +1,35 @@ +Name: systemAppearanceChanged + +Type: message + +Syntax: systemAppearanceChanged + +Summary: +Sent to the of the when the +changes. + +Associations: card + +Introduced: 1.0 + +OS: mac, ios, android + +Platforms: desktop,mobile + +Example: +on systemAppearanceChanged + if the systemAppearance is "dark" then + set the backColor of me to "black" + set the foreColor of me to "white" + else + set the backColor of me to "white" + set the foreColor of me to "black" + end if +on systemAppearanceChanged + +Description: +Handle the if you need to change the color +of objects when the application enters either light or dark mode. + +References: systemAppearance (property), message (glossary), defaultStack (property) + diff --git a/docs/dictionary/property/systemAppearance.lcdoc b/docs/dictionary/property/systemAppearance.lcdoc new file mode 100644 index 00000000000..94e2d77fc06 --- /dev/null +++ b/docs/dictionary/property/systemAppearance.lcdoc @@ -0,0 +1,30 @@ +Name: systemAppearance + +Type: property + +Syntax: get the systemAppearance + +Summary: +Determins if the system appearance is dark or light mode. + +Introduced: 9.6 + +OS: mac, android, ios + +Platforms: desktop, mobile + +Example: +if the systemAppearance is "dark" then + set the backColor of me to "black" + set the foreColor of me to "white" +else + set the backColor of me to "white" + set the foreColor of me to "black" +end if + +Description: +The property returns either "dark" or "light" depending on +whether the application is running in a dark mode context or not. On windows +and linux the property will return "light". + +References: systemAppearanceChanged (message) diff --git a/docs/notes/bugfix-22607.md b/docs/notes/bugfix-22607.md new file mode 100644 index 00000000000..573ce305e20 --- /dev/null +++ b/docs/notes/bugfix-22607.md @@ -0,0 +1,7 @@ +# Dark mode detection + +A new `systemAppearance` property has been added which returns `dark` if +the application is running in dark mode and `light` otherwise. + +A new `systemAppearanceChanged` message is now sent to the current card of the +defaultStack when the system appearance changes. \ No newline at end of file diff --git a/engine/src/desktop-dc.cpp b/engine/src/desktop-dc.cpp index 45422fd8f97..9e16846a84f 100644 --- a/engine/src/desktop-dc.cpp +++ b/engine/src/desktop-dc.cpp @@ -944,6 +944,13 @@ void MCScreenDC::closeIME() //////////////////////////////////////////////////////////////////////////////// +void MCScreenDC::getsystemappearance(MCSystemAppearance &r_appearance) +{ + MCPlatformGetSystemProperty(kMCPlatformSystemPropertySystemAppearance, kMCPlatformPropertyTypeInt32, &r_appearance); +} + +//////////////////////////////////////////////////////////////////////////////// + extern bool MCListSystemPrinters(MCStringRef &); extern MCPrinter *MCCreateSystemPrinter(void); diff --git a/engine/src/desktop-dc.h b/engine/src/desktop-dc.h index 430349141da..0743af1ab32 100644 --- a/engine/src/desktop-dc.h +++ b/engine/src/desktop-dc.h @@ -142,7 +142,9 @@ class MCScreenDC: public MCUIDC // MW-2014-04-26: [[ Bug 5545 ]] Override this method to defer to the MCPlatform method. virtual void hidecursoruntilmousemoves(void); - + + virtual void getsystemappearance(MCSystemAppearance &r_appearance); + ////////// bool isbackdrop(MCPlatformWindowRef window); diff --git a/engine/src/desktop.cpp b/engine/src/desktop.cpp index f2c00257d9f..1a5dfa8519b 100644 --- a/engine/src/desktop.cpp +++ b/engine/src/desktop.cpp @@ -164,6 +164,16 @@ void MCPlatformHandleScreenParametersChanged(void) //////////////////////////////////////////////////////////////////////////////// +void MCPlatformHandleSystemAppearanceChanged(void) +{ + if (MCscreen == nil) + return; + + MCscreen -> delaymessage(MCdefaultstackptr -> getcurcard(), MCM_system_appearance_changed); +} + +//////////////////////////////////////////////////////////////////////////////// + #if defined (FEATURE_PLATFORM_WINDOW) void MCPlatformHandleWindowCloseRequest(MCPlatformWindowRef p_window) { diff --git a/engine/src/exec-interface2.cpp b/engine/src/exec-interface2.cpp index 08dd8010fda..f873fd9475a 100644 --- a/engine/src/exec-interface2.cpp +++ b/engine/src/exec-interface2.cpp @@ -432,6 +432,21 @@ static MCExecEnumTypeInfo _kMCInterfaceSelectionModeTypeInfo = _kMCInterfaceSelectionModeElementInfo, }; +////////// + +static MCExecEnumTypeElementInfo _kMCInterfaceSystemAppearanceElementInfo[] = +{ + { "light", 0, false }, + { "dark", 1, false }, +}; + +static MCExecEnumTypeInfo _kMCInterfaceSystemAppearanceTypeInfo = +{ + "Interface.ProcessType", + sizeof(_kMCInterfaceSystemAppearanceElementInfo) / sizeof(MCExecEnumTypeElementInfo), + _kMCInterfaceSystemAppearanceElementInfo, +}; + //////////////////////////////////////////////////////////////////////////////// MCExecEnumTypeInfo *kMCInterfaceLookAndFeelTypeInfo = &_kMCInterfaceLookAndFeelTypeInfo; @@ -441,6 +456,7 @@ MCExecEnumTypeInfo *kMCInterfacePaintCompressionTypeInfo = &_kMCInterfacePaintCo MCExecEnumTypeInfo *kMCInterfaceProcessTypeTypeInfo = &_kMCInterfaceProcessTypeTypeInfo; MCExecEnumTypeInfo *kMCInterfaceSelectionModeTypeInfo = &_kMCInterfaceSelectionModeTypeInfo; MCExecCustomTypeInfo *kMCInterfaceStackFileVersionTypeInfo = &_kMCInterfaceStackFileVersionTypeInfo; +MCExecEnumTypeInfo *kMCInterfaceSystemAppearanceTypeInfo = &_kMCInterfaceSystemAppearanceTypeInfo; //////////////////////////////////////////////////////////////////////////////// @@ -1701,6 +1717,13 @@ void MCInterfaceSetSelectionMode(MCExecContext& ctxt, intenum_t p_value) MCselectintersect = (Boolean)p_value; } +void MCInterfaceGetSystemAppearance(MCExecContext& ctxt, intenum_t& r_value) +{ + MCSystemAppearance t_appearance; + MCscreen->getsystemappearance(t_appearance); + r_value = (intenum_t)t_appearance; +} + void MCInterfaceGetSelectionHandleColor(MCExecContext& ctxt, MCInterfaceNamedColor& r_color) { get_interface_color(MCselectioncolor, MCselectioncolorname, r_color); diff --git a/engine/src/exec.h b/engine/src/exec.h index e752fabdc0b..e68c31272cf 100644 --- a/engine/src/exec.h +++ b/engine/src/exec.h @@ -2182,6 +2182,7 @@ extern MCExecCustomTypeInfo *kMCInterfaceVisualEffectArgumentTypeInfo; extern MCExecCustomTypeInfo *kMCInterfaceButtonIconTypeInfo; extern MCExecCustomTypeInfo *kMCInterfaceTriStateTypeInfo; extern MCExecCustomTypeInfo *kMCInterfaceStackFileVersionTypeInfo; +extern MCExecEnumTypeInfo *kMCInterfaceSystemAppearanceTypeInfo; void MCInterfaceInitialize(MCExecContext& ctxt); void MCInterfaceFinalize(MCExecContext& ctxt); @@ -2645,6 +2646,7 @@ void MCInterfaceGetScreenGamma(MCExecContext& ctxt, double& r_value); void MCInterfaceSetScreenGamma(MCExecContext& ctxt, double p_value); void MCInterfaceGetSelectionMode(MCExecContext& ctxt, intenum_t& r_value); void MCInterfaceSetSelectionMode(MCExecContext& ctxt, intenum_t p_value); +void MCInterfaceGetSystemAppearance(MCExecContext& ctxt, intenum_t& r_value); void MCInterfaceGetSelectionHandleColor(MCExecContext& ctxt, MCInterfaceNamedColor& r_color); void MCInterfaceSetSelectionHandleColor(MCExecContext& ctxt, const MCInterfaceNamedColor& p_color); void MCInterfaceGetWindowBoundingRect(MCExecContext& ctxt, MCRectangle& r_value); diff --git a/engine/src/java/com/runrev/android/Engine.java b/engine/src/java/com/runrev/android/Engine.java index 57c182ce03f..f15a7f37de9 100644 --- a/engine/src/java/com/runrev/android/Engine.java +++ b/engine/src/java/com/runrev/android/Engine.java @@ -138,6 +138,8 @@ public class Engine extends View implements EngineApi private boolean m_new_intent; private int m_photo_width, m_photo_height; + + private int m_night_mode; //////////////////////////////////////////////////////////////////////////////// @@ -239,6 +241,10 @@ public void onScreenOrientationChanged(int orientation) m_photo_width = 0; m_photo_height = 0; + + m_night_mode = + p_context.getResources().getConfiguration().uiMode & + Configuration.UI_MODE_NIGHT_MASK; } //////////////////////////////////////////////////////////////////////////////// @@ -356,6 +362,15 @@ public String loadExternalLibrary(String name) public void onConfigurationChanged(Configuration p_new_config) { + int t_night_mode = + getContext().getResources().getConfiguration().uiMode & + Configuration.UI_MODE_NIGHT_MASK; + + if (t_night_mode != m_night_mode) + { + m_night_mode = t_night_mode; + doSystemAppearanceChanged(); + } } //////////////////////////////////////////////////////////////////////////////// @@ -3882,7 +3897,22 @@ public Class getServiceClass() { return ((LiveCodeActivity)getContext()).getServiceClass(); } - + + //////////////////////////////////////////////////////////////////////////////// + + public int getSystemAppearance() + { + switch (m_night_mode) + { + case Configuration.UI_MODE_NIGHT_YES: + return 1; + case Configuration.UI_MODE_NIGHT_NO: + case Configuration.UI_MODE_NIGHT_UNDEFINED: + default: + return 0; + } + } + //////////////////////////////////////////////////////////////////////////////// // url launch callback @@ -3952,6 +3982,7 @@ public static native void doHeadingChanged(double p_heading, double p_magnetic_h public static native void doShake(int action, long timestamp); public static native void doOrientationChanged(int orientation); + public static native void doSystemAppearanceChanged(); public static native void doKeyboardShown(int height); public static native void doKeyboardHidden(); diff --git a/engine/src/lextable.cpp b/engine/src/lextable.cpp index 19b94a3b37a..39af33e9ea5 100644 --- a/engine/src/lextable.cpp +++ b/engine/src/lextable.cpp @@ -1690,7 +1690,8 @@ const LT factor_table[] = {"syncrate", TT_PROPERTY, P_SYNC_RATE}, {"syserror", TT_FUNCTION, F_SYS_ERROR}, {"system", TT_PROPERTY, P_SYSTEM}, - {"systemcolorselector", TT_PROPERTY, P_SYSTEM_CS}, + {"systemappearance", TT_PROPERTY, P_SYSTEM_APPEARANCE}, + {"systemcolorselector", TT_PROPERTY, P_SYSTEM_CS}, {"systemfileselector", TT_PROPERTY, P_SYSTEM_FS}, // IM-2013-12-04: [[ PixelScale ]] The "systemPixelScale" token {"systempixelscale", TT_PROPERTY, P_SYSTEM_PIXEL_SCALE}, diff --git a/engine/src/mac-core.mm b/engine/src/mac-core.mm index 1fc629e5bbc..7bce664a156 100644 --- a/engine/src/mac-core.mm +++ b/engine/src/mac-core.mm @@ -342,12 +342,21 @@ - (void)applicationDidFinishLaunching: (NSNotification *)notification [t_event release]; } + + [[NSDistributedNotificationCenter defaultCenter] addObserver:self + selector:@selector(interfaceThemeChangedNotification:) + name:@"AppleInterfaceThemeChangedNotification" object:nil]; // We started up successfully, so queue the root runloop invocation // message. [self performSelector: @selector(runMainLoop) withObject: nil afterDelay: 0]; } +- (void)interfaceThemeChangedNotification:(NSNotification *)notification +{ + MCPlatformCallbackSendSystemAppearanceChanged(); +} + - (void)runMainLoop { for(;;) @@ -608,7 +617,21 @@ void MCPlatformGetSystemProperty(MCPlatformSystemProperty p_property, MCPlatform case kMCPlatformSystemPropertyVolume: MCMacPlatformGetGlobalVolume(*(double *)r_value); break; - + + case kMCPlatformSystemPropertySystemAppearance: + { + NSUserDefaults *t_defaults = [NSUserDefaults standardUserDefaults]; + NSString *t_appearance = [t_defaults stringForKey:@"AppleInterfaceStyle"]; + if (t_appearance == nil || ![t_appearance isEqualToString:@"Dark"]) + { + *(int16_t *)r_value = kMCPlatformSystemAppearanceLight; + } + else + { + *(int16_t *)r_value = kMCPlatformSystemAppearanceDark; + } + } + break; default: assert(false); break; diff --git a/engine/src/mblandroiddc.cpp b/engine/src/mblandroiddc.cpp index 85d4c81a540..281b832c929 100644 --- a/engine/src/mblandroiddc.cpp +++ b/engine/src/mblandroiddc.cpp @@ -737,6 +737,16 @@ Window MCScreenDC::get_current_window(void) //////////////////////////////////////////////////////////////////////////////// +void MCScreenDC::getsystemappearance(MCSystemAppearance &r_appearance) +{ + int t_system_appearance; + MCAndroidEngineRemoteCall("getSystemAppearance", "i", &t_system_appearance); + + r_appearance = static_cast(t_system_appearance); +} + +//////////////////////////////////////////////////////////////////////////////// + static MCRectangle android_view_get_bounds(void) { return MCRectangleMake(s_android_bitmap_loc_x, s_android_bitmap_loc_y, s_android_bitmap_width, s_android_bitmap_height); @@ -2032,6 +2042,7 @@ extern "C" JNIEXPORT void JNICALL Java_com_runrev_android_Engine_doBackPressed(J extern "C" JNIEXPORT void JNICALL Java_com_runrev_android_Engine_doMenuKey(JNIEnv *env, jobject object) __attribute__((visibility("default"))); extern "C" JNIEXPORT void JNICALL Java_com_runrev_android_Engine_doSearchKey(JNIEnv *env, jobject object) __attribute__((visibility("default"))); extern "C" JNIEXPORT void JNICALL Java_com_runrev_android_Engine_doOrientationChanged(JNIEnv *env, jobject object, jint orientation) __attribute__((visibility("default"))); +extern "C" JNIEXPORT void JNICALL Java_com_runrev_android_Engine_doSystemAppearanceChanged(JNIEnv *env, jobject object) __attribute__((visibility("default"))); extern "C" JNIEXPORT void JNICALL Java_com_runrev_android_Engine_doTextDone(JNIEnv *env, jobject object) __attribute__((visibility("default"))); extern "C" JNIEXPORT void JNICALL Java_com_runrev_android_Engine_doTextCanceled(JNIEnv *env, jobject object) __attribute__((visibility("default"))); extern "C" JNIEXPORT void JNICALL Java_com_runrev_android_Engine_doMediaDone(JNIEnv *env, jobject object, jstring p_media_content) __attribute__((visibility("default"))); @@ -2375,6 +2386,13 @@ JNIEXPORT void JNICALL Java_com_runrev_android_Engine_doOrientationChanged(JNIEn ////////// +JNIEXPORT void JNICALL Java_com_runrev_android_Engine_doSystemAppearanceChanged(JNIEnv *env, jobject object) +{ + MCNotificationPostSystemAppearanceChanged(); +} + +////////// + struct MCKeyboardActivatedEvent: public MCCustomEvent { MCKeyboardActivatedEvent(float p_height) diff --git a/engine/src/mbldc.h b/engine/src/mbldc.h index 0a298e225e7..c6d81aa9e70 100644 --- a/engine/src/mbldc.h +++ b/engine/src/mbldc.h @@ -245,6 +245,8 @@ class MCScreenDC: public MCUIDC Window get_current_window(void); void refresh_current_window(void); + + void getsystemappearance(MCSystemAppearance &r_appearance); private: // The top-left of the mobile 'window' in screen co-ordinates. int32_t m_window_left; diff --git a/engine/src/mbliphoneapp.mm b/engine/src/mbliphoneapp.mm index bcfe90d967a..d5f0aa71d4e 100644 --- a/engine/src/mbliphoneapp.mm +++ b/engine/src/mbliphoneapp.mm @@ -1973,6 +1973,11 @@ - (void)voiceOverStatusChanged } } +- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection +{ + MCNotificationPostSystemAppearanceChanged(); +} + @end //////////////////////////////////////////////////////////////////////////////// diff --git a/engine/src/mbliphonedc.mm b/engine/src/mbliphonedc.mm index 8c4f74b90c5..50729f4b935 100644 --- a/engine/src/mbliphonedc.mm +++ b/engine/src/mbliphonedc.mm @@ -857,6 +857,22 @@ static void MCScreenDCDoSnapshot(void *p_env) //////////////////////////////////////////////////////////////////////////////// +void MCScreenDC::getsystemappearance(MCSystemAppearance &r_appearance) +{ + UITraitCollection *t_traits = [MCIPhoneGetRootView() traitCollection]; + if ([t_traits respondsToSelector: @selector(userInterfaceStyle)] && + [t_traits userInterfaceStyle] == 2 /* UIUserInterfaceStyleDark */) + { + r_appearance = kMCSystemAppearanceDark; + } + else + { + r_appearance = kMCSystemAppearanceLight; + } +} + +//////////////////////////////////////////////////////////////////////////////// + extern void *coretext_font_create_with_name_size_and_style(MCStringRef p_name, uint32_t p_size, bool p_bold, bool p_italic); extern bool coretext_font_destroy(void *p_font); extern bool coretext_font_get_metrics(void *p_font, float& r_ascent, float& r_descent, float& r_leading, float& r_xheight); diff --git a/engine/src/mblnotification.cpp b/engine/src/mblnotification.cpp index a59703d5bd8..53c36beb755 100644 --- a/engine/src/mblnotification.cpp +++ b/engine/src/mblnotification.cpp @@ -180,4 +180,9 @@ void MCNotificationPostLaunchDataChanged() /* UNCHECKED */ MCNotificationPostCustom(MCM_launch_data_changed, 0); } +void MCNotificationPostSystemAppearanceChanged() +{ + /* UNCHECKED */ MCNotificationPostCustom(MCM_system_appearance_changed, 0); +} + //////////////////////////////////////////////////////////////////////////////// diff --git a/engine/src/mblnotification.h b/engine/src/mblnotification.h index b9b833da72c..5dec994dea6 100644 --- a/engine/src/mblnotification.h +++ b/engine/src/mblnotification.h @@ -25,6 +25,7 @@ void MCNotificationPostPushRegistered (MCStringRef p_registration_text); void MCNotificationPostPushRegistrationError (MCStringRef p_error_text); void MCNotificationPostUrlWakeUp (MCStringRef p_url_wake_up_text); void MCNotificationPostLaunchDataChanged(); +void MCNotificationPostSystemAppearanceChanged(); bool MCNotificationPostCustom(MCNameRef p_message, uint32_t p_param_count, ...); #endif diff --git a/engine/src/mcstring.cpp b/engine/src/mcstring.cpp index 2455369c622..d1e9a16e245 100644 --- a/engine/src/mcstring.cpp +++ b/engine/src/mcstring.cpp @@ -632,6 +632,8 @@ MCNameRef MCN_font_message; MCNameRef MCN_font_tooltip; MCNameRef MCN_font_system; +MCNameRef MCM_system_appearance_changed; + const struct { const char *cstring; MCNameRef *name_var; } kInitialNames[] = { { "msg", &MCN_msg }, @@ -958,6 +960,7 @@ const struct { const char *cstring; MCNameRef *name_var; } kInitialNames[] = { "unloadURL", &MCM_unload_url }, { "updateScreen", &MCM_update_screen }, { "updateVariable", &MCM_update_var }, + { "systemAppearanceChanged", &MCM_system_appearance_changed }, #ifdef FEATURE_PLATFORM_URL { "urlProgress", &MCM_url_progress }, diff --git a/engine/src/mcstring.h b/engine/src/mcstring.h index cc3debf1a99..9dbeff6fb90 100644 --- a/engine/src/mcstring.h +++ b/engine/src/mcstring.h @@ -635,3 +635,5 @@ extern MCNameRef MCN_font_content; // Control contents extern MCNameRef MCN_font_message; // Message boxes and status messages extern MCNameRef MCN_font_tooltip; // Tooltip text extern MCNameRef MCN_font_system; // Anything else not covered above + +extern MCNameRef MCM_system_appearance_changed; diff --git a/engine/src/parsedef.h b/engine/src/parsedef.h index d360752dff2..480e706428c 100644 --- a/engine/src/parsedef.h +++ b/engine/src/parsedef.h @@ -1758,6 +1758,8 @@ enum Properties { P_REV_LIBRARY_MAPPING, P_LAYER_CLIP_RECT, + + P_SYSTEM_APPEARANCE, __P_LAST, }; diff --git a/engine/src/platform-internal.h b/engine/src/platform-internal.h index a9338ace69c..ccd19e9e726 100644 --- a/engine/src/platform-internal.h +++ b/engine/src/platform-internal.h @@ -325,6 +325,7 @@ void MCPlatformCallbackSendApplicationSuspend(void); void MCPlatformCallbackSendApplicationResume(void); void MCPlatformCallbackSendScreenParametersChanged(void); +void MCPlatformCallbackSendSystemAppearanceChanged(void); void MCPlatformCallbackSendWindowCloseRequest(MCPlatformWindowRef window); void MCPlatformCallbackSendWindowClose(MCPlatformWindowRef window); diff --git a/engine/src/platform.cpp b/engine/src/platform.cpp index ab7a81f2468..a170154107c 100644 --- a/engine/src/platform.cpp +++ b/engine/src/platform.cpp @@ -29,6 +29,7 @@ void MCPlatformHandleApplicationResume(void); void MCPlatformHandleApplicationRun(bool& r_continue); void MCPlatformHandleScreenParametersChanged(void); +void MCPlatformHandleSystemAppearanceChanged(void); void MCPlatformHandleWindowCloseRequest(MCPlatformWindowRef window); void MCPlatformHandleWindowClose(MCPlatformWindowRef window); @@ -129,6 +130,13 @@ void MCPlatformCallbackSendScreenParametersChanged(void) ////////// +void MCPlatformCallbackSendSystemAppearanceChanged(void) +{ + MCPlatformHandleSystemAppearanceChanged(); +} + +////////// + #if defined(FEATURE_PLATFORM_WINDOW) void MCPlatformCallbackSendWindowCloseRequest(MCPlatformWindowRef p_window) diff --git a/engine/src/platform.h b/engine/src/platform.h index a9406a97173..cd8a631b76a 100644 --- a/engine/src/platform.h +++ b/engine/src/platform.h @@ -487,11 +487,19 @@ enum MCPlatformSystemProperty kMCPlatformSystemPropertyCursorImageSupport, kMCPlatformSystemPropertyVolume, + + kMCPlatformSystemPropertySystemAppearance, }; void MCPlatformGetSystemProperty(MCPlatformSystemProperty property, MCPlatformPropertyType type, void *value); void MCPlatformSetSystemProperty(MCPlatformSystemProperty property, MCPlatformPropertyType type, void *value); +enum MCPlatformSystemAppearance +{ + kMCPlatformSystemAppearanceLight = 0, + kMCPlatformSystemAppearanceDark = 1, +}; + //////////////////////////////////////////////////////////////////////////////// typedef bool (*MCPlatformPreWaitForEventCallback)(double duration, bool blocking); diff --git a/engine/src/property.cpp b/engine/src/property.cpp index bd61a6b7776..d0eeb694a38 100644 --- a/engine/src/property.cpp +++ b/engine/src/property.cpp @@ -403,6 +403,8 @@ static MCPropertyInfo kMCPropertyInfoTable[] = // MW-2014-12-10: [[ Extensions ]] Returns a list of loaded extensions. DEFINE_RO_PROPERTY(P_LOADED_EXTENSIONS, ProperLinesOfString, Engine, LoadedExtensions) + + DEFINE_RO_ENUM_PROPERTY(P_SYSTEM_APPEARANCE, InterfaceSystemAppearance, Interface, SystemAppearance) }; static bool MCPropertyInfoTableLookup(Properties p_which, Boolean p_effective, const MCPropertyInfo*& r_info, bool p_is_array_prop) @@ -940,6 +942,7 @@ Parse_stat MCProperty::parse(MCScriptPoint &sp, Boolean the) // MW-2014-12-10: [[ Extensions ]] Add support for global loadedExtensions property. case P_LOADED_EXTENSIONS: + case P_SYSTEM_APPEARANCE: break; case P_REV_LIBRARY_MAPPING: diff --git a/engine/src/uidc.cpp b/engine/src/uidc.cpp index dfdb44e6031..2e004601839 100644 --- a/engine/src/uidc.cpp +++ b/engine/src/uidc.cpp @@ -2039,3 +2039,11 @@ void MCUIDC::modalLoopEnd() m_modal_loops = m_modal_loops->chain; } +//////////////////////////////////////////////////////////////////////////////// + +void MCUIDC::getsystemappearance(MCSystemAppearance &r_appearance) +{ + r_appearance = kMCSystemAppearanceLight; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/engine/src/uidc.h b/engine/src/uidc.h index 5844e7b5dd8..9f98e7abbde 100644 --- a/engine/src/uidc.h +++ b/engine/src/uidc.h @@ -323,6 +323,12 @@ enum MCPlatformFeature PLATFORM_FEATURE_TRANSIENT_SELECTION }; +enum MCSystemAppearance +{ + kMCSystemAppearanceLight = 0, + kMCSystemAppearanceDark = 1, +}; + class MCUIDC { public: @@ -654,6 +660,8 @@ class MCUIDC // MW-2014-04-26: [[ Bug 5545 ]] Hides the cursor until the mouse moves on platforms which // require this action. virtual void hidecursoruntilmousemoves(void); + + virtual void getsystemappearance(MCSystemAppearance &r_appearance); // diff --git a/ide-support/revsaveasandroidstandalone.livecodescript b/ide-support/revsaveasandroidstandalone.livecodescript index cbc6f008a2e..ef45e76c02c 100644 --- a/ide-support/revsaveasandroidstandalone.livecodescript +++ b/ide-support/revsaveasandroidstandalone.livecodescript @@ -587,8 +587,7 @@ private command revSaveAsMobileStandaloneMain pStack, pApkFile, pTarget, pSettin // SN-2015-09-24: [[ Bug 15875 ]] Add the screenSize configChanges value for API > 12 // Otherwise the app restarts on orientation change. local tConfigChangesProp - put "keyboardHidden|orientation" into tConfigChangesProp - put "|screenSize" after tConfigChangesProp + put "keyboardHidden|orientation|uiMode|screenSize" into tConfigChangesProp replace "${CONFIG_CHANGES}" with tConfigChangesProp in tManifest // SN-2015-09-30: [[ Bug 10267 ]] Hardware Acceleration option added