Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'vibra_notification_hint' into 'master'
Vibra notification hint

See merge request !80
  • Loading branch information
pvuorela committed Feb 8, 2018
2 parents 690a693 + e433cae commit b6fe13b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 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
8 changes: 6 additions & 2 deletions src/notifications/notificationmanager.cpp
Expand Up @@ -333,10 +333,14 @@ uint NotificationManager::Notify(const QString &appName, uint replacesId, const
priority = m_androidPriorityStore->appDetails(appName);
}
hints_.insert(LipstickNotification::HINT_PRIORITY, priority.first);

if (!priority.second.isEmpty()) {
hints_.insert(LipstickNotification::HINT_FEEDBACK, priority.second);
// Also turn the display on if required
hints_.insert(LipstickNotification::HINT_DISPLAY_ON, true);
// Also turn the display on if required, but only if it's really playing vibra or sound feedback
if (hints_.value(LipstickNotification::HINT_VIBRA, false).toBool()
|| !hints_.value(LipstickNotification::HINT_SUPPRESS_SOUND, false).toBool()) {
hints_.insert(LipstickNotification::HINT_DISPLAY_ON, true);
}
}
} else {
if (notification->appName().isEmpty() && !pidProperties.first.isEmpty()) {
Expand Down

0 comments on commit b6fe13b

Please sign in to comment.