Skip to content

Commit 79d10e5

Browse files
committed
Fix bugs for data files and key events
* Data files will be created in application's private area. * Key event including Shift key value will be handled properly.
1 parent c93a5cc commit 79d10e5

File tree

3 files changed

+29
-22
lines changed

3 files changed

+29
-22
lines changed

packages/webview_flutter/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ This package is not an _endorsed_ implementation of `webview_flutter`. Therefore
2525
```yaml
2626
dependencies:
2727
webview_flutter: ^1.0.6
28-
webview_flutter_tizen: ^1.0.0
28+
webview_flutter_tizen: ^0.1.0
2929
```
3030
31-
To enable tizen implementation, you can refer to the following:
31+
## Example
3232
3333
```dart
3434
import 'dart:io';

packages/webview_flutter/tizen/src/webview.cc

+14-15
Original file line numberDiff line numberDiff line change
@@ -495,9 +495,17 @@ static LWE::KeyValue EcoreEventKeyToKeyValue(const char* ecore_key_string,
495495
}
496496
return (LWE::KeyValue)(LWE::KeyValue::Digit0Key + ch - '0');
497497
} else if (ch >= 'a' && ch <= 'z') {
498-
return (LWE::KeyValue)(LWE::KeyValue::LowerAKey + ch - 'a');
498+
if (is_shift_pressed) {
499+
return (LWE::KeyValue)(LWE::KeyValue::LowerAKey + ch - 'a' - 32);
500+
} else {
501+
return (LWE::KeyValue)(LWE::KeyValue::LowerAKey + ch - 'a');
502+
}
499503
} else if (ch >= 'A' && ch <= 'Z') {
500-
return (LWE::KeyValue)(LWE::KeyValue::AKey + ch - 'A');
504+
if (is_shift_pressed) {
505+
return (LWE::KeyValue)(LWE::KeyValue::AKey + ch - 'A' + 32);
506+
} else {
507+
return (LWE::KeyValue)(LWE::KeyValue::AKey + ch - 'A');
508+
}
501509
}
502510
} else if (strcmp("XF86AudioRaiseVolume", ecore_key_string) == 0) {
503511
return LWE::KeyValue::TVVolumeUpKey;
@@ -583,12 +591,6 @@ void WebView::DispatchKeyDownEvent(Ecore_Event_Key* key_event) {
583591
return;
584592
}
585593

586-
#ifdef TV_PROFILE
587-
if ((strncmp(key_name.data(), "XF86Back", 8) == 0)) {
588-
key_name = "Escape";
589-
}
590-
#endif
591-
592594
if ((strcmp(key_name.data(), "XF86Exit") == 0) ||
593595
(strcmp(key_name.data(), "Select") == 0) ||
594596
(strcmp(key_name.data(), "Cancel") == 0)) {
@@ -620,7 +622,8 @@ void WebView::DispatchKeyDownEvent(Ecore_Event_Key* key_event) {
620622
};
621623
Param* p = new Param();
622624
p->webview_instance = webview_instance_;
623-
p->key_value = EcoreEventKeyToKeyValue(key_name.data(), false);
625+
p->key_value =
626+
EcoreEventKeyToKeyValue(key_name.data(), (key_event->modifiers & 1));
624627

625628
webview_instance_->AddIdleCallback(
626629
[](void* data) {
@@ -642,18 +645,14 @@ void WebView::DispatchKeyUpEvent(Ecore_Event_Key* key_event) {
642645
return;
643646
}
644647

645-
#ifdef TV_PROFILE
646-
if ((strncmp(key_name.data(), "XF86Back", 8) == 0)) {
647-
key_name = "Escape";
648-
}
649-
#endif
650648
struct Param {
651649
LWE::WebContainer* webview_instance;
652650
LWE::KeyValue key_value;
653651
};
654652
Param* p = new Param();
655653
p->webview_instance = webview_instance_;
656-
p->key_value = EcoreEventKeyToKeyValue(key_name.data(), false);
654+
p->key_value =
655+
EcoreEventKeyToKeyValue(key_name.data(), (key_event->modifiers & 1));
657656

658657
webview_instance_->AddIdleCallback(
659658
[](void* data) {

packages/webview_flutter/tizen/src/webview_factory.cc

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "webview_factory.h"
22

3+
#include <app_common.h>
34
#include <flutter/method_channel.h>
45
#include <flutter/plugin_registrar.h>
56
#include <flutter/standard_message_codec.h>
@@ -19,14 +20,21 @@
1920
WebViewFactory::WebViewFactory(flutter::PluginRegistrar* registrar,
2021
FlutterTextureRegistrar* textureRegistrar)
2122
: PlatformViewFactory(registrar), textureRegistrar_(textureRegistrar) {
22-
// temporlal soluation
23-
std::string localstoragePath =
24-
"/tmp/" + std::string("StarFish_localStorage.db");
25-
std::string cookiePath = "/tmp/" + std::string("StarFish_cookies.db");
26-
std::string cachePath = "/tmp/" + std::string("Starfish_cache.db");
23+
char* path = app_get_data_path();
24+
if (!path || strlen(path) == 0) {
25+
path = "/tmp/";
26+
}
27+
std::string localstoragePath = path + std::string("StarFish_localStorage.db");
28+
std::string cookiePath = path + std::string("StarFish_cookies.db");
29+
std::string cachePath = path + std::string("Starfish_cache.db");
2730

2831
LWE::LWE::Initialize(localstoragePath.c_str(), cookiePath.c_str(),
2932
cachePath.c_str());
33+
34+
if (path) {
35+
free(path);
36+
path = nullptr;
37+
}
3038
}
3139

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

0 commit comments

Comments
 (0)