Skip to content

Commit

Permalink
Add some notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
xfangfang committed Sep 6, 2024
1 parent 02cb634 commit d336dfa
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 40 deletions.
2 changes: 2 additions & 0 deletions resources/i18n/en-US/wiliwili.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@
"dlna_waiting": "Waiting for DLNA casting...",
"dlna_quit": "Exit the DLNA casting?",
"up2date": "App is up to date",
"checking_update": "Checking for updates...",
"release": "Check for updates",
"config_dir": "Config directory",
"config": "Open config directory"
}
},
Expand Down
2 changes: 2 additions & 0 deletions resources/i18n/zh-Hans/wiliwili.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@
"dlna_waiting": "等待 DLNA 投屏中...",
"dlna_quit": "确定要退出投屏?",
"up2date": "应用已经是最新版",
"checking_update": "正在检查更新...",
"release": "检查更新",
"config_dir": "配置目录",
"config": "打开配置目录"
}
},
Expand Down
2 changes: 2 additions & 0 deletions resources/i18n/zh-Hant/wiliwili.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@
"dlna_waiting": "等待 DLNA 投映中...",
"dlna_quit": "確定要退出投映?",
"up2date": "應用程式為最新版本。",
"checking_update": "正在檢查更新...",
"release": "檢查更新",
"config_dir": "設定檔目錄",
"config": "開啟設定檔目錄"
}
},
Expand Down
16 changes: 0 additions & 16 deletions resources/xml/fragment/share_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,4 @@

</brls:Box>

<brls:Box
cornerRadius="4"
backgroundColor="@theme/brls/backdrop"
positionBottom="150"
positionLeft="300"
positionType="absolute"
justifyContent="center"
alignItems="center"
visibility="gone"
id="share/hint/box">
<brls:Label
margin="10"
textColor="#FFFFFF"
text="@i18n/wiliwili/player/clipboard" />
</brls:Box>

</brls:Box>
1 change: 0 additions & 1 deletion wiliwili/include/fragment/share_dialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class ShareDialog : public brls::Box {
private:
BRLS_BIND(QRImage, qrcode, "share/qrcode");
BRLS_BIND(brls::Box, boxShare, "share/box");
BRLS_BIND(brls::Box, boxHint, "share/hint/box");
BRLS_BIND(ShareBox, qq, "share/box/qq");
BRLS_BIND(ShareBox, qzone, "share/box/qzone");
BRLS_BIND(ShareBox, tieba, "share/box/tieba");
Expand Down
29 changes: 20 additions & 9 deletions wiliwili/source/activity/setting_activity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,20 +189,31 @@ void SettingActivity::onContentAvailable() {
return true;
});

#if !defined(__SWITCH__) && !defined(IOS) && !defined(__PSV__) && !defined(PS4)
btnOpenConfig->registerClickAction([](...) -> bool {
auto* p = (brls::DesktopPlatform*)brls::Application::getPlatform();
p->openBrowser(ProgramConfig::instance().getConfigDir());
return true;
});
#if defined(__SWITCH__) || defined(__PSV__) || defined(PS4)
btnOpenConfig->title->setText("wiliwili/setting/tools/others/config_dir"_i18n);
#endif
#ifdef __linux__
if (brls::isSteamDeck()) {
btnOpenConfig->setVisibility(brls::Visibility::GONE);
btnOpenConfig->title->setText("wiliwili/setting/tools/others/config_dir"_i18n);
}
#endif
btnOpenConfig->registerClickAction([](...) -> bool {
auto configPath = ProgramConfig::instance().getConfigDir();
brls::Application::notify("wiliwili/setting/tools/others/config_dir"_i18n + ": " + configPath);
#if !defined(__SWITCH__) && !defined(__PSV__) && !defined(PS4)
#ifdef __linux__
if (!brls::isSteamDeck())
#else
btnOpenConfig->setVisibility(brls::Visibility::GONE);
{
auto* p = (brls::DesktopPlatform*)brls::Application::getPlatform();
p->openBrowser(configPath);
}
#endif
#endif
return true;
});


btnTutorialFont->registerClickAction([](...) -> bool {
auto dialog =
new brls::Dialog((brls::Box*)brls::View::createFromXMLResource("fragment/settings_tutorial_font.xml"));
Expand Down Expand Up @@ -241,7 +252,7 @@ void SettingActivity::onContentAvailable() {
btnReleaseChecker->title->setText("wiliwili/setting/tools/others/release"_i18n + " (" + "hints/current"_i18n +
": " + version + ")");
btnReleaseChecker->registerClickAction([](...) -> bool {
// todo: 弹出一个提示提醒用户正在检查更新
brls::Application::notify("wiliwili/setting/tools/others/checking_update"_i18n);
APPVersion::instance().checkUpdate(0, true);
return true;
});
Expand Down
13 changes: 3 additions & 10 deletions wiliwili/source/fragment/share_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "view/qr_image.hpp"
#include "view/button_close.hpp"

using namespace brls::literals;

ShareBox::ShareBox() {
this->inflateFromXMLRes("xml/fragment/share_box.xml");
this->registerStringXMLAttribute("title", [this](const std::string& value) { this->title->setText(value); });
Expand Down Expand Up @@ -80,9 +82,6 @@ void ShareDialog::open(const std::string& link, const std::string& title, const
"url={}&type=3&count=1&appkey=2841902482&title={}&pic={}&language=zh_cn",
cpr::util::urlEncode(link), cpr::util::urlEncode(title + "#哔哩哔哩动画#"), cpr::util::urlEncode(pic)));

this->boxHint->hide([]() {}, false, 0);
this->boxHint->setVisibility(brls::Visibility::VISIBLE);

this->dynamic->setLink(link);
this->dynamic->getEvent()->subscribe([this]() { this->showHint(); });
this->wechat->setLink(link);
Expand All @@ -95,11 +94,5 @@ void ShareDialog::open(const std::string& link, const std::string& title, const
ShareDialog::~ShareDialog() { brls::Logger::debug("Fragment ShareDialog: delete"); }

void ShareDialog::showHint() {
ASYNC_RETAIN
this->boxHint->show([ASYNC_TOKEN]() {
brls::delay(500, [ASYNC_TOKEN]() {
ASYNC_RELEASE
this->boxHint->hide([]() {});
});
});
brls::Application::notify("wiliwili/player/clipboard"_i18n);
}
7 changes: 5 additions & 2 deletions wiliwili/source/presenter/video_detail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,8 @@ void VideoDetail::beAgree(uint64_t aid) {
[ASYNC_TOKEN](BILI_ERR) {
// 请求失败 恢复默认状态
brls::Logger::error("{}", error);
brls::sync([ASYNC_TOKEN]() {
brls::sync([ASYNC_TOKEN, error]() {
brls::Application::notify(error);
ASYNC_RELEASE
this->onVideoRelationInfo(videoRelation);
});
Expand Down Expand Up @@ -648,6 +649,7 @@ void VideoDetail::addCoin(uint64_t aid, int num, bool like) {
// 请求失败 恢复默认状态
brls::Logger::error("{}", error);
brls::sync([ASYNC_TOKEN, error]() {
brls::Application::notify(error);
ASYNC_RELEASE
// 投币达到上限
if (pystring::count(error, "34005")) videoRelation.coin = 2;
Expand Down Expand Up @@ -679,7 +681,8 @@ void VideoDetail::addResource(uint64_t aid, int type, bool isFavorite, std::stri
[ASYNC_TOKEN](BILI_ERR) {
// 请求失败 恢复默认状态
brls::Logger::error("{}", error);
brls::sync([ASYNC_TOKEN]() {
brls::sync([ASYNC_TOKEN, error]() {
brls::Application::notify(error);
ASYNC_RELEASE
this->onVideoRelationInfo(videoRelation);
});
Expand Down
6 changes: 5 additions & 1 deletion wiliwili/source/utils/version_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,16 @@ bool APPVersion::needUpdate(std::string latestVersion) {
}

void APPVersion::checkUpdate(int delay, bool showUpToDateDialog) {
static bool checking_update = false;
if (checking_update) return;
checking_update = true;
brls::Threading::delay(delay, [showUpToDateDialog]() {
std::string url =
ProgramConfig::instance().getSettingItem(SettingItem::CUSTOM_UPDATE_API, APPVersion::RELEASE_API);

cpr::GetCallback(
[showUpToDateDialog](cpr::Response r) {
checking_update = false;
try {
if (r.status_code != 200 || r.text.empty()) {
brls::Logger::error("Cannot check update: {} {}", r.status_code, r.text);
Expand All @@ -98,7 +102,7 @@ void APPVersion::checkUpdate(int delay, bool showUpToDateDialog) {
brls::Logger::info("App is up to date");
if (showUpToDateDialog) {
brls::sync(
[]() { DialogHelper::showDialog("wiliwili/setting/tools/others/up2date"_i18n); });
[]() { brls::Application::notify("wiliwili/setting/tools/others/up2date"_i18n); });
}
return;
}
Expand Down

0 comments on commit d336dfa

Please sign in to comment.