Skip to content

Commit

Permalink
Fix bugs for data files and key events
Browse files Browse the repository at this point in the history
* Data files will be created in application's private area.
* Key event including Shift key value will be handled properly.
  • Loading branch information
seungsoo47 committed Apr 5, 2021
1 parent c93a5cc commit 968c170
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
29 changes: 14 additions & 15 deletions packages/webview_flutter/tizen/src/webview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -495,9 +495,17 @@ static LWE::KeyValue EcoreEventKeyToKeyValue(const char* ecore_key_string,
}
return (LWE::KeyValue)(LWE::KeyValue::Digit0Key + ch - '0');
} else if (ch >= 'a' && ch <= 'z') {
return (LWE::KeyValue)(LWE::KeyValue::LowerAKey + ch - 'a');
if (is_shift_pressed) {
return (LWE::KeyValue)(LWE::KeyValue::LowerAKey + ch - 'a' - 32);
} else {
return (LWE::KeyValue)(LWE::KeyValue::LowerAKey + ch - 'a');
}
} else if (ch >= 'A' && ch <= 'Z') {
return (LWE::KeyValue)(LWE::KeyValue::AKey + ch - 'A');
if (is_shift_pressed) {
return (LWE::KeyValue)(LWE::KeyValue::AKey + ch - 'A' + 32);
} else {
return (LWE::KeyValue)(LWE::KeyValue::AKey + ch - 'A');
}
}
} else if (strcmp("XF86AudioRaiseVolume", ecore_key_string) == 0) {
return LWE::KeyValue::TVVolumeUpKey;
Expand Down Expand Up @@ -583,12 +591,6 @@ void WebView::DispatchKeyDownEvent(Ecore_Event_Key* key_event) {
return;
}

#ifdef TV_PROFILE
if ((strncmp(key_name.data(), "XF86Back", 8) == 0)) {
key_name = "Escape";
}
#endif

if ((strcmp(key_name.data(), "XF86Exit") == 0) ||
(strcmp(key_name.data(), "Select") == 0) ||
(strcmp(key_name.data(), "Cancel") == 0)) {
Expand Down Expand Up @@ -620,7 +622,8 @@ void WebView::DispatchKeyDownEvent(Ecore_Event_Key* key_event) {
};
Param* p = new Param();
p->webview_instance = webview_instance_;
p->key_value = EcoreEventKeyToKeyValue(key_name.data(), false);
p->key_value =
EcoreEventKeyToKeyValue(key_name.data(), (key_event->modifiers & 1));

webview_instance_->AddIdleCallback(
[](void* data) {
Expand All @@ -642,18 +645,14 @@ void WebView::DispatchKeyUpEvent(Ecore_Event_Key* key_event) {
return;
}

#ifdef TV_PROFILE
if ((strncmp(key_name.data(), "XF86Back", 8) == 0)) {
key_name = "Escape";
}
#endif
struct Param {
LWE::WebContainer* webview_instance;
LWE::KeyValue key_value;
};
Param* p = new Param();
p->webview_instance = webview_instance_;
p->key_value = EcoreEventKeyToKeyValue(key_name.data(), false);
p->key_value =
EcoreEventKeyToKeyValue(key_name.data(), (key_event->modifiers & 1));

webview_instance_->AddIdleCallback(
[](void* data) {
Expand Down
18 changes: 13 additions & 5 deletions packages/webview_flutter/tizen/src/webview_factory.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "webview_factory.h"

#include <app_common.h>
#include <flutter/method_channel.h>
#include <flutter/plugin_registrar.h>
#include <flutter/standard_message_codec.h>
Expand All @@ -19,14 +20,21 @@
WebViewFactory::WebViewFactory(flutter::PluginRegistrar* registrar,
FlutterTextureRegistrar* textureRegistrar)
: PlatformViewFactory(registrar), textureRegistrar_(textureRegistrar) {
// temporlal soluation
std::string localstoragePath =
"/tmp/" + std::string("StarFish_localStorage.db");
std::string cookiePath = "/tmp/" + std::string("StarFish_cookies.db");
std::string cachePath = "/tmp/" + std::string("Starfish_cache.db");
char* path = app_get_data_path();
if (!path || strlen(path) == 0) {
path = "/tmp/";
}
std::string localstoragePath = path + std::string("StarFish_localStorage.db");
std::string cookiePath = path + std::string("StarFish_cookies.db");
std::string cachePath = path + std::string("Starfish_cache.db");

LWE::LWE::Initialize(localstoragePath.c_str(), cookiePath.c_str(),
cachePath.c_str());

if (path) {
free(path);
path = nullptr;
}
}

PlatformView* WebViewFactory::Create(int viewId, double width, double height,
Expand Down

0 comments on commit 968c170

Please sign in to comment.