Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[lipstick] Add support for vibration notification hint. Contributes t…
…o JB#38924

Used already by aliendalvik. Now for those notification vibra gets
played only when application really requested it. Fixes issues
when overridden apps sometimes have vibra and sometimes not
for different kinds of notitications.

Assuming there's a vibra feedback ngfd event provided for this.
  • Loading branch information
pvuorela committed Feb 2, 2018
1 parent 6a37b5b commit 9fde2b2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/notifications/lipsticknotification.cpp
Expand Up @@ -47,6 +47,7 @@ const char *LipstickNotification::HINT_OWNER = "x-nemo-owner";
const char *LipstickNotification::HINT_MAX_CONTENT_LINES = "x-nemo-max-content-lines";
const char *LipstickNotification::HINT_RESTORED = "x-nemo-restored";
const char *LipstickNotification::HINT_PROGRESS = "x-nemo-progress";
const char *LipstickNotification::HINT_VIBRA = "x-nemo-vibrate";

LipstickNotification::LipstickNotification(const QString &appName, const QString &disambiguatedAppName, uint id,
const QString &appIcon, const QString &summary, const QString &body,
Expand Down
3 changes: 3 additions & 0 deletions src/notifications/lipsticknotification.h
Expand Up @@ -139,6 +139,9 @@ class LIPSTICK_EXPORT LipstickNotification : public QObject
//! Nemo hint: progress percentage between 0 and 1, negative for indeterminate
static const char *HINT_PROGRESS;

//! Nemo hint: play vibra feedback
static const char *HINT_VIBRA;

/*!
* Creates an object for storing information about a single notification.
*
Expand Down
18 changes: 7 additions & 11 deletions src/notifications/notificationfeedbackplayer.cpp
Expand Up @@ -72,24 +72,20 @@ void NotificationFeedbackPlayer::addNotification(uint id)
if (notification->hints().value(LipstickNotification::HINT_SUPPRESS_SOUND, false).toBool()) {
properties.insert("media.audio", false);
}

if (!properties.isEmpty()) {
// Add any unspecified properties as true, or they are treated as false (when properties is non-empty)
if (!properties.contains("media.leds")) {
properties.insert("media.leds", true);
}
if (!properties.contains("media.audio")) {
properties.insert("media.audio", true);
}
properties.insert("media.vibra", true);
properties.insert("media.backlight", true);
if (!notification->hints().value(LipstickNotification::HINT_ORIGIN_PACKAGE).toString().isEmpty()) {
// android notification, play vibra only when explicitly asked via separate hint
properties.insert("media.vibra", false);
}

foreach (const QString &item, feedbackItems) {
m_ngfClient->stop(item);
m_idToEventId.insert(notification, m_ngfClient->play(item, properties));
}
}
if (notification->hints().value(LipstickNotification::HINT_VIBRA, false).toBool()) {
m_ngfClient->stop("vibra");
m_idToEventId.insert(notification, m_ngfClient->play("vibra", QMap<QString, QVariant>()));
}
}
}

Expand Down

0 comments on commit 9fde2b2

Please sign in to comment.