forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create channels directory * Handle back button events
- Loading branch information
Showing
17 changed files
with
248 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "navigation_channel.h" | ||
|
||
#include "flutter/shell/platform/common/cpp/json_method_codec.h" | ||
#include "flutter/shell/platform/tizen/logger.h" | ||
|
||
static constexpr char kChannelName[] = "flutter/navigation"; | ||
|
||
static constexpr char kSetInitialRouteMethod[] = "setInitialRoute"; | ||
static constexpr char kPushRouteMethod[] = "pushRoute"; | ||
static constexpr char kPopRouteMethod[] = "popRoute"; | ||
|
||
NavigationChannel::NavigationChannel(flutter::BinaryMessenger* messenger) | ||
: channel_(std::make_unique<flutter::MethodChannel<rapidjson::Document>>( | ||
messenger, kChannelName, &flutter::JsonMethodCodec::GetInstance())) {} | ||
|
||
NavigationChannel::~NavigationChannel() {} | ||
|
||
void NavigationChannel::SetInitialRoute(const std::string& initialRoute) { | ||
auto args = std::make_unique<rapidjson::Document>(rapidjson::kObjectType); | ||
args->Parse("\"" + initialRoute + "\""); | ||
|
||
if (!args->HasParseError()) { | ||
channel_->InvokeMethod(kSetInitialRouteMethod, std::move(args)); | ||
} | ||
} | ||
|
||
void NavigationChannel::PushRoute(const std::string& route) { | ||
auto args = std::make_unique<rapidjson::Document>(rapidjson::kObjectType); | ||
args->Parse("\"" + route + "\""); | ||
|
||
if (!args->HasParseError()) { | ||
channel_->InvokeMethod(kPushRouteMethod, std::move(args)); | ||
} | ||
} | ||
|
||
void NavigationChannel::PopRoute() { | ||
channel_->InvokeMethod(kPopRouteMethod, nullptr); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef EMBEDDER_NAVIGATION_CHANNEL_H_ | ||
#define EMBEDDER_NAVIGATION_CHANNEL_H_ | ||
|
||
#include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/binary_messenger.h" | ||
#include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/method_channel.h" | ||
#include "rapidjson/document.h" | ||
|
||
class NavigationChannel { | ||
public: | ||
explicit NavigationChannel(flutter::BinaryMessenger* messenger); | ||
virtual ~NavigationChannel(); | ||
|
||
void SetInitialRoute(const std::string& initialRoute); | ||
void PushRoute(const std::string& route); | ||
void PopRoute(); | ||
|
||
private: | ||
std::unique_ptr<flutter::MethodChannel<rapidjson::Document>> channel_; | ||
}; | ||
|
||
#endif // EMBEDDER_NAVIGATION_CHANNEL_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "platform_channel.h" | ||
|
||
#include "flutter/shell/platform/common/cpp/json_method_codec.h" | ||
#include "flutter/shell/platform/tizen/logger.h" | ||
|
||
static constexpr char kChannelName[] = "flutter/platform"; | ||
|
||
PlatformChannel::PlatformChannel(flutter::BinaryMessenger* messenger) | ||
: channel_(std::make_unique<flutter::MethodChannel<rapidjson::Document>>( | ||
messenger, kChannelName, &flutter::JsonMethodCodec::GetInstance())) { | ||
channel_->SetMethodCallHandler( | ||
[this]( | ||
const flutter::MethodCall<rapidjson::Document>& call, | ||
std::unique_ptr<flutter::MethodResult<rapidjson::Document>> result) { | ||
HandleMethodCall(call, std::move(result)); | ||
}); | ||
} | ||
|
||
PlatformChannel::~PlatformChannel() {} | ||
|
||
void PlatformChannel::HandleMethodCall( | ||
const flutter::MethodCall<rapidjson::Document>& call, | ||
std::unique_ptr<flutter::MethodResult<rapidjson::Document>> result) { | ||
const auto method = call.method_name(); | ||
|
||
if (method == "SystemNavigator.pop") { | ||
exit(EXIT_SUCCESS); | ||
result->Success(); | ||
} else if (method == "SystemSound.play") { | ||
result->NotImplemented(); | ||
} else if (method == "HapticFeedback.vibrate") { | ||
result->NotImplemented(); | ||
} else if (method == "Clipboard.getData") { | ||
result->NotImplemented(); | ||
} else if (method == "Clipboard.setData") { | ||
result->NotImplemented(); | ||
} else if (method == "Clipboard.hasStrings") { | ||
result->NotImplemented(); | ||
} else if (method == "SystemChrome.setPreferredOrientations") { | ||
result->NotImplemented(); | ||
} else if (method == "SystemChrome.setApplicationSwitcherDescription") { | ||
result->NotImplemented(); | ||
} else if (method == "SystemChrome.setEnabledSystemUIOverlays") { | ||
result->NotImplemented(); | ||
} else if (method == "SystemChrome.restoreSystemUIOverlays") { | ||
result->NotImplemented(); | ||
} else if (method == "SystemChrome.setSystemUIOverlayStyle") { | ||
result->NotImplemented(); | ||
} else { | ||
LoggerI("Unimplemented method: %s", method.c_str()); | ||
result->NotImplemented(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef EMBEDDER_PLATFORM_CHANNEL_H_ | ||
#define EMBEDDER_PLATFORM_CHANNEL_H_ | ||
|
||
#include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/binary_messenger.h" | ||
#include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/method_channel.h" | ||
#include "rapidjson/document.h" | ||
|
||
class PlatformChannel { | ||
public: | ||
explicit PlatformChannel(flutter::BinaryMessenger* messenger); | ||
virtual ~PlatformChannel(); | ||
|
||
private: | ||
std::unique_ptr<flutter::MethodChannel<rapidjson::Document>> channel_; | ||
|
||
void HandleMethodCall( | ||
const flutter::MethodCall<rapidjson::Document>& call, | ||
std::unique_ptr<flutter::MethodResult<rapidjson::Document>> result); | ||
}; | ||
|
||
#endif // EMBEDDER_PLATFORM_CHANNEL_H_ |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters