-
Notifications
You must be signed in to change notification settings - Fork 17
Add high contrast accessibility support for TV #237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,69 @@ | ||||||
| // Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved. | ||||||
| // Use of this source code is governed by a BSD-style license that can be | ||||||
| // found in the LICENSE file. | ||||||
|
|
||||||
| #include "accessibility_settings.h" | ||||||
|
|
||||||
| #ifdef TV_PROFILE | ||||||
| #include <system/system_settings.h> | ||||||
| #endif | ||||||
|
|
||||||
| #include "flutter/shell/platform/tizen/flutter_tizen_engine.h" | ||||||
| #include "flutter/shell/platform/tizen/logger.h" | ||||||
|
|
||||||
| // SYSTEM_SETTINGS_KEY_MENU_SYSTEM_ACCESSIBILITY_HIGHCONTRAST = 10059 has been | ||||||
| // defined in system_settings_keys.h only for TV profile. | ||||||
| #define SYSTEM_SETTINGS_KEY_MENU_SYSTEM_ACCESSIBILITY_HIGHCONTRAST 10059 | ||||||
|
|
||||||
| namespace flutter { | ||||||
|
|
||||||
| AccessibilitySettings::AccessibilitySettings(FlutterTizenEngine* engine) | ||||||
| : engine_(engine) { | ||||||
| #ifdef TV_PROFILE | ||||||
| // Add listener for accessibility high contrast. | ||||||
| system_settings_set_changed_cb( | ||||||
| system_settings_key_e( | ||||||
| SYSTEM_SETTINGS_KEY_MENU_SYSTEM_ACCESSIBILITY_HIGHCONTRAST), | ||||||
| [](system_settings_key_e key, void* user_data) -> void { | ||||||
| auto* self = reinterpret_cast<AccessibilitySettings*>(user_data); | ||||||
| self->OnHighContrastStateChanged(); | ||||||
| }, | ||||||
| this); | ||||||
|
|
||||||
| // Set initialized value of accessibility high contrast. | ||||||
| if (engine_ != nullptr) { | ||||||
| engine_->EnableAccessibilityFeature(GetHighContrastValue()); | ||||||
| } | ||||||
| #endif | ||||||
| } | ||||||
|
|
||||||
| AccessibilitySettings::~AccessibilitySettings() { | ||||||
| #ifdef TV_PROFILE | ||||||
| system_settings_unset_changed_cb(system_settings_key_e( | ||||||
| SYSTEM_SETTINGS_KEY_MENU_SYSTEM_ACCESSIBILITY_HIGHCONTRAST)); | ||||||
| #endif | ||||||
| } | ||||||
|
|
||||||
| void AccessibilitySettings::OnHighContrastStateChanged() { | ||||||
| if (engine_ != nullptr) { | ||||||
| engine_->EnableAccessibilityFeature(GetHighContrastValue()); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| bool AccessibilitySettings::GetHighContrastValue() { | ||||||
| int enabled = 0; | ||||||
| #ifdef TV_PROFILE | ||||||
| int ret = system_settings_get_value_int( | ||||||
| system_settings_key_e( | ||||||
| SYSTEM_SETTINGS_KEY_MENU_SYSTEM_ACCESSIBILITY_HIGHCONTRAST), | ||||||
| &enabled); | ||||||
| if (ret != SYSTEM_SETTINGS_ERROR_NONE) { | ||||||
| FT_LOG(Error) | ||||||
| << "Failed to get value of accessibility high contrast. ERROR CODE = " | ||||||
| << ret; | ||||||
| } | ||||||
| #endif | ||||||
| return enabled; | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You might simply change the return type to
Suggested change
By the way cannot
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I had tried system_settings_set_value_bool, but met the parameter error
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Thanks for your review. I have modified all of them. |
||||||
| } | ||||||
|
|
||||||
| } // namespace flutter | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // Copyright 2022 Samsung Electronics Co., Ltd. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #ifndef EMBEDDER_ACCESSIBILITY_SETTINGS_H_ | ||
| #define EMBEDDER_ACCESSIBILITY_SETTINGS_H_ | ||
|
|
||
| namespace flutter { | ||
|
|
||
| class FlutterTizenEngine; | ||
|
|
||
| class AccessibilitySettings { | ||
| public: | ||
| explicit AccessibilitySettings(FlutterTizenEngine* engine); | ||
| virtual ~AccessibilitySettings(); | ||
|
|
||
| void OnHighContrastStateChanged(); | ||
|
|
||
| private: | ||
| bool GetHighContrastValue(); | ||
|
|
||
| FlutterTizenEngine* engine_; | ||
| }; | ||
|
|
||
| } // namespace flutter | ||
|
|
||
| #endif // EMBEDDER_ACCESSIBILITY_SETTINGS_H_ |
Uh oh!
There was an error while loading. Please reload this page.