Hide native notification details on lock screen.

This commit is contained in:
John Preston 2021-04-27 13:51:52 +04:00
parent e9196bbbb5
commit e26e666135
7 changed files with 16 additions and 19 deletions

View file

@ -727,10 +727,6 @@ bool SkipFlashBounce() {
return Inhibited();
}
bool HideDetails() {
return false;
}
bool Supported() {
return ServiceRegistered;
}

View file

@ -159,10 +159,6 @@ bool SkipFlashBounce() {
return SkipAudio();
}
bool HideDetails() {
return Global::ScreenIsLocked();
}
bool Supported() {
return Platform::IsMac10_8OrGreater();
}

View file

@ -15,7 +15,6 @@ namespace Notifications {
[[nodiscard]] bool SkipAudio();
[[nodiscard]] bool SkipToast();
[[nodiscard]] bool SkipFlashBounce();
[[nodiscard]] bool HideDetails();
[[nodiscard]] bool Supported();
[[nodiscard]] bool Enforced();

View file

@ -823,9 +823,5 @@ bool SkipFlashBounce() {
return SkipToast();
}
bool HideDetails() {
return false;
}
} // namespace Notifications
} // namespace Platform

View file

@ -576,9 +576,10 @@ void System::updateAll() {
}
}
Manager::DisplayOptions Manager::GetNotificationOptions(HistoryItem *item) {
Manager::DisplayOptions Manager::getNotificationOptions(
HistoryItem *item) const {
const auto hideEverything = Core::App().passcodeLocked()
|| Platform::Notifications::HideDetails();
|| forceHideDetails();
const auto view = Core::App().settings().notifyView();
DisplayOptions result;
@ -696,7 +697,7 @@ void Manager::notificationReplied(
void NativeManager::doShowNotification(
not_null<HistoryItem*> item,
int forwardedCount) {
const auto options = GetNotificationOptions(item);
const auto options = getNotificationOptions(item);
const auto peer = item->history()->peer;
const auto scheduled = !options.hideNameAndPhoto
@ -732,6 +733,10 @@ void NativeManager::doShowNotification(
options.hideReplyButton);
}
bool NativeManager::forceHideDetails() const {
return Global::ScreenIsLocked();
}
System::~System() = default;
QString WrapFromScheduled(const QString &text) {

View file

@ -193,8 +193,8 @@ public:
bool hideMessageText = false;
bool hideReplyButton = false;
};
[[nodiscard]] static DisplayOptions GetNotificationOptions(
HistoryItem *item);
[[nodiscard]] DisplayOptions getNotificationOptions(
HistoryItem *item) const;
[[nodiscard]] QString addTargetAccountName(
const QString &title,
@ -218,6 +218,9 @@ protected:
virtual void doClearFromItem(not_null<HistoryItem*> item) = 0;
virtual void doClearFromHistory(not_null<History*> history) = 0;
virtual void doClearFromSession(not_null<Main::Session*> session) = 0;
[[nodiscard]] virtual bool forceHideDetails() const {
return false;
}
virtual void onBeforeNotificationActivated(NotificationId id) {
}
virtual void onAfterNotificationActivated(
@ -256,6 +259,8 @@ protected:
not_null<HistoryItem*> item,
int forwardedCount) override;
bool forceHideDetails() const override;
virtual void doShowNativeNotification(
not_null<PeerData*> peer,
std::shared_ptr<Data::CloudImageView> &userpicView,

View file

@ -725,7 +725,7 @@ void Notification::actionsOpacityCallback() {
void Notification::updateNotifyDisplay() {
if (!_history || (!_item && _forwardedCount < 2)) return;
const auto options = Manager::GetNotificationOptions(_item);
const auto options = manager()->getNotificationOptions(_item);
_hideReplyButton = options.hideReplyButton;
int32 w = width(), h = height();