-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
integrate AlertToast for notification
- Loading branch information
1 parent
77ec5b9
commit 9a603d3
Showing
18 changed files
with
172 additions
and
11 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
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 |
---|---|---|
@@ -1,2 +1,5 @@ | ||
add_library(FcitxCommon common.cpp) | ||
target_include_directories(FcitxCommon PRIVATE | ||
"${PROJECT_SOURCE_DIR}/fcitx5/src/modules/notifications" | ||
) | ||
target_link_libraries(FcitxCommon Fcitx5::Core) |
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
Submodule AlertToast
added at
6e902e
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 @@ | ||
add_subdirectory(AlertToast) |
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,30 @@ | ||
add_library(NotifySwift STATIC notify.swift toast.swift) | ||
set_target_properties(NotifySwift PROPERTIES Swift_MODULE_NAME NotifySwift) | ||
target_compile_options(NotifySwift PUBLIC "$<$<COMPILE_LANGUAGE:Swift>:-cxx-interoperability-mode=default>") | ||
|
||
_swift_generate_cxx_header( | ||
NotifySwift | ||
"${CMAKE_CURRENT_BINARY_DIR}/include/notify-swift.h" | ||
SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/notify.swift" | ||
SEARCH_PATHS "${CMAKE_CURRENT_SOURCE_DIR}" | ||
) | ||
|
||
add_library(iosnotifications iosnotifications.cpp) | ||
add_dependencies(iosnotifications NotifySwift) | ||
target_include_directories(iosnotifications PUBLIC | ||
"${CMAKE_CURRENT_BINARY_DIR}/include" | ||
) | ||
target_link_libraries(iosnotifications Fcitx5::Core Fcitx5::Module::Notifications) | ||
|
||
configure_file(notifications.conf.in.in notifications.conf.in @ONLY) | ||
fcitx5_translate_desktop_file(${CMAKE_CURRENT_BINARY_DIR}/notifications.conf.in notifications.conf) | ||
|
||
add_custom_command( | ||
TARGET iosnotifications | ||
POST_BUILD COMMAND /bin/sh -c | ||
\" | ||
${CMAKE_COMMAND} -E copy | ||
${CMAKE_CURRENT_BINARY_DIR}/notifications.conf | ||
${PROJECT_BINARY_DIR}/keyboard/$<CONFIG>${CMAKE_XCODE_EFFECTIVE_PLATFORMS}/keyboard.appex/share/fcitx5/addon/notifications.conf | ||
\" | ||
) |
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,29 @@ | ||
#include "iosnotifications.h" | ||
#include "notify-swift.h" | ||
|
||
namespace fcitx { | ||
Notifications::Notifications(Instance *instance) {} | ||
|
||
uint32_t Notifications::sendNotification( | ||
const std::string &appName, uint32_t replaceId, const std::string &appIcon, | ||
const std::string &summary, const std::string &body, | ||
const std::vector<std::string> &actions, int32_t timeout, | ||
NotificationActionCallback actionCallback, | ||
NotificationClosedCallback closedCallback) { | ||
|
||
FCITX_INFO() << "sendNotification " << body; | ||
return 0; | ||
} | ||
|
||
void Notifications::showTip(const std::string &tipId, | ||
const std::string &appName, | ||
const std::string &appIcon, | ||
const std::string &summary, const std::string &body, | ||
int32_t timeout) { | ||
NotifySwift::showTip(body, timeout); | ||
} | ||
|
||
void Notifications::closeNotification(uint64_t internalId) { | ||
FCITX_INFO() << "closeNotification " << internalId; | ||
} | ||
} // namespace fcitx |
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,39 @@ | ||
#pragma once | ||
|
||
#include <fcitx/addonfactory.h> | ||
#include <fcitx/addoninstance.h> | ||
#include <fcitx/addonmanager.h> | ||
#include <fcitx/instance.h> | ||
#include <notifications_public.h> | ||
|
||
namespace fcitx { | ||
class Notifications final : public AddonInstance { | ||
public: | ||
Notifications(Instance *instance); | ||
~Notifications() = default; | ||
uint32_t sendNotification(const std::string &appName, uint32_t replaceId, | ||
const std::string &appIcon, | ||
const std::string &summary, | ||
const std::string &body, | ||
const std::vector<std::string> &actions, | ||
int32_t timeout, | ||
NotificationActionCallback actionCallback, | ||
NotificationClosedCallback closedCallback); | ||
void showTip(const std::string &tipId, const std::string &appName, | ||
const std::string &appIcon, const std::string &summary, | ||
const std::string &body, int32_t timeout); | ||
|
||
void closeNotification(uint64_t internalId); | ||
|
||
private: | ||
FCITX_ADDON_EXPORT_FUNCTION(Notifications, sendNotification); | ||
FCITX_ADDON_EXPORT_FUNCTION(Notifications, showTip); | ||
FCITX_ADDON_EXPORT_FUNCTION(Notifications, closeNotification); | ||
}; | ||
|
||
class IosNotificationsFactory : public AddonFactory { | ||
AddonInstance *create(AddonManager *manager) override { | ||
return new Notifications(manager->instance()); | ||
} | ||
}; | ||
} // namespace fcitx |
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,7 @@ | ||
[Addon] | ||
Name=iOS Notification | ||
Type=StaticLibrary | ||
Library=libiosnotifications | ||
Category=Module | ||
Version=@PROJECT_VERSION@ | ||
Configurable=True |
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,6 @@ | ||
public func showTip(_ body: String, _ timeout: Int32) { | ||
guard let showToastCallback = showToastCallback else { | ||
return | ||
} | ||
showToastCallback(body, timeout) | ||
} |
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,5 @@ | ||
var showToastCallback: ((String, Int32) -> Void)? | ||
|
||
public func setShowToastCallback(_ callback: @escaping (String, Int32) -> Void) { | ||
showToastCallback = callback | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
find common src keyboard iosfrontend uipanel -name '*.cpp' -o -name '*.h' | xargs clang-format -i | ||
swift-format format --in-place $(find src keyboard iosfrontend uipanel protocol ipc -name '*.swift') | ||
find common src keyboard iosfrontend iosnotifications uipanel -name '*.cpp' -o -name '*.h' | xargs clang-format -i | ||
swift-format format --in-place $(find src keyboard iosfrontend iosnotifications uipanel protocol ipc -name '*.swift') |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
set -e | ||
|
||
find common src keyboard iosfrontend uipanel -name '*.cpp' -o -name '*.h' | xargs clang-format -Werror --dry-run | ||
swift-format lint -rs src keyboard iosfrontend uipanel protocol ipc | ||
find common src keyboard iosfrontend iosnotifications uipanel -name '*.cpp' -o -name '*.h' | xargs clang-format -Werror --dry-run | ||
swift-format lint -rs src keyboard iosfrontend iosnotifications uipanel protocol ipc |
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