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(); return Inhibited();
} }
bool HideDetails() {
return false;
}
bool Supported() { bool Supported() {
return ServiceRegistered; return ServiceRegistered;
} }

View file

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

View file

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

View file

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

View file

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

View file

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