Skip to content

Commit

Permalink
Merge branch 'jb51257' into 'upgrade-3.4.0'
Browse files Browse the repository at this point in the history
[lipstick] Backport notification changes to 3.4.0. Contributes to JB#51257

See merge request mer-core/lipstick!162
  • Loading branch information
adenexter committed Oct 20, 2020
2 parents 6c7bc76 + e59431b commit 0cc2da9
Show file tree
Hide file tree
Showing 49 changed files with 473 additions and 559 deletions.
21 changes: 3 additions & 18 deletions doc/src/notifications.dox
Expand Up @@ -13,14 +13,9 @@
*
* - Some optional features of the specification are not supported: body text
* containing markup is not supported.
* - Multiple actions per notification are correctly handled, but the user
* interface provides no means for displaying or activating actions other
* than "default".
* - Some standard hints are not supported. These are:
* - 'action-icons'
* - 'desktop-entry'
* - 'image-data'
* - 'sound-name'
* - 'x'
* - 'y'
*
Expand Down Expand Up @@ -80,22 +75,17 @@
* the hints of the notification, unless already defined.
*
* - The service supports the following Nemo specific hints:
* - \c x-nemo-icon: icon ID or path for the notification. This may be a file:// URL, else if the string begins with a / it's interpreted to be an absolute path. Otherwise it's interpreted to be an icon ID, in which case the icon with the given ID is fetched from the theme. This hint is deprecated in favor of the standard \c image-path hint.
* - \c x-nemo-item-count: the number of items represented by this notification. For example, a single notification can represent four missed calls by setting the count to 4.
* - \c x-nemo-priority: the priority of the notification as an integer. Priorities can be used by UI implementations to present notifications in a specific order, for example. If not specified, the priority level will be allocated 50.
* - \c x-nemo-timestamp: the timestamp for the notification. Should be set to the time when the event the notification is related to has occurred, not when the notification itself was sent.
* - \c x-nemo-preview-icon: icon ID or path to use in the preview banner for the notification, if any.
* - \c x-nemo-preview-body: body text to be shown in the preview banner for the notification, if any.
* - \c x-nemo-preview-summary: summary text to be shown in the preview banner for the notification, if any.
* - \c x-nemo-max-content-lines: the maximum number of content lines to display in the events view, inclusive of the summary. If 1, then no body lines will be displayed.
* - \c x-nemo-remote-action-actionname: details of the D-Bus call to be made when the action "actionname" is executed. "actionname" should be listed in the notification's \c actions array. The required format is "serviceName objectPath interface methodName [argument...]", where each argument must be separately encoded by serializing to QDataStream, then encoding the resulting byte sequence to Base64.
* - \c x-nemo-visibility: the confidentiality of the notification. Currently allows "public" to make notification show even on locked device, "private" and "secret" like on Android API might come later if needed.
*
* - The following hints are used by system notifications, and may be excluded from application notifications:
* - \c x-nemo-feedback: a token used to generate a pre-defined feedback event when the notification preview is displayed
* - \c x-nemo-display-on: if true, the display will be turned on when required for the duration of the notification preview
* - \c x-nemo-led-disabled-without-body-and-summary: if false, a notification may invoke a feedback event even with empty body and summary properties
* - \c x-nemo-hidden: if true, the notification is not displayed and does not cause any feedback to be invoked
* - \c x-nemo-user-removable: a boolean value for defining whether the user is able to remove the notification manually; otherwise it may only be removed programmatically. Defaults to true.
*
* \section howto How to use notifications in various use cases
Expand All @@ -120,8 +110,6 @@
* - \c hints should contain the following:
* - \c category should be "im.received" to categorize the notification to be related to an instant message
* - \c urgency should be 1 (normal) since chat messages are not specifically low or high priority
* - \c x-nemo-icon should be "icon-lock-chat" to define that the icon with that ID is to be shown on the notification area
* - \c x-nemo-preview-icon should be "icon-preview-chat" to define that the icon with that ID is to be shown on the preview banner
* - \c x-nemo-preview-summary should match the summary text ("John Doe") in order to show it also on the preview banner
* - \c x-nemo-preview-body should match the body text ("Hi!") in order to show it also on the preview banner
* - \c x-nemo-timestamp should be set to the time when the chat message was sent (or received, depending on the intended application logic)
Expand All @@ -144,9 +132,7 @@
* - \c hints should contain the following:
* - \c category should be "im.received" to categorize the notification to be related to an instant message
* - \c urgency should be 1 (normal) since chat messages are not specifically low or high priority
* - \c x-nemo-icon should be "icon-lock-chat" to define that the icon with that ID is to be shown on the notification area
* - \c x-nemo-item-count should be 2 to make the notification represent two chat messages
* - \c x-nemo-preview-icon should be "icon-preview-chat" to define that the icon with that ID is to be shown on the preview banner
* - \c x-nemo-preview-summary should contain a brief description about the notification to be shown on the preview banner, like "John Doe"
* - \c x-nemo-preview-body should contain informative text about the notification to be shown on the preview banner, like "Are you there?"
* - \c x-nemo-timestamp should be set to the time when the latest chat message was sent (or received, depending on the intended application logic)
Expand Down Expand Up @@ -177,15 +163,14 @@
* When calling Notify() to a display a transient notification, the parameters should be set as follows:
* - \c app_name should be a string identifying the sender application, such as the name of its binary, for example. "batterynotifier"
* - \c replaces_id should be 0 since the notification is a new one and not related to any existing notification
* - \c app_icon should be left empty; it will not be used in this scenario
* - \c app_icon should be "icon-battery-low" to define that the icon with that ID is to be shown on the preview banner
* - \c summary should be left empty for nothing to be shown in the events view
* - \c body should be left empty for nothing to be shown in the events view
* - \c actions should be left empty
* - \c hints should contain the following:
* - \c category should be "device" to categorize the notification to be related to the device
* - \c urgency should be 2 (critical) to show the notification over the lock screen
* - \c transient should be true to automatically close the notification after display
* - \c x-nemo-preview-icon should be "icon-battery-low" to define that the icon with that ID is to be shown on the preview banner
* - \c x-nemo-preview-body should be "Battery low" in order to show it on the preview banner
* - \c expire_timeout should be -1 to let the notification manager choose an appropriate expiration time
*
Expand All @@ -205,7 +190,7 @@
* \code
* transient=true
* urgency=2
* x-nemo-preview-icon=icon-battery-low
* app_icon=icon-battery-low
* \endcode
*
* and Notify() is called with the hints dictionary containing the value \c "device"
Expand All @@ -217,7 +202,7 @@
* transient=true
* urgency=2
* x-nemo-preview-body=Charging
* x-nemo-preview-icon=icon-battery-low
* app_icon=icon-battery-low
* \endcode
*
* It is also possible to define the following notification properties in the category
Expand Down
6 changes: 6 additions & 0 deletions src/androidnotificationpriorities
Expand Up @@ -51,3 +51,9 @@ package:eu.siacs.conversations;chat,chat_exists

K9-Mail;email,email_exists
package:com.fsck.k9;email,email_exists

Teams;chat,chat_exists
package:com.microsoft.teams;chat,chat_exists

Messenger Lite;chat,chat_exists
package:com.facebook.mlite;chat,chat_exists
4 changes: 0 additions & 4 deletions src/notificationcategories/device.added.conf

This file was deleted.

3 changes: 0 additions & 3 deletions src/notificationcategories/device.conf

This file was deleted.

4 changes: 0 additions & 4 deletions src/notificationcategories/device.error.conf

This file was deleted.

4 changes: 0 additions & 4 deletions src/notificationcategories/device.removed.conf

This file was deleted.

3 changes: 0 additions & 3 deletions src/notificationcategories/network.conf

This file was deleted.

3 changes: 0 additions & 3 deletions src/notificationcategories/network.connected.conf

This file was deleted.

3 changes: 0 additions & 3 deletions src/notificationcategories/network.disconnected.conf

This file was deleted.

3 changes: 0 additions & 3 deletions src/notificationcategories/network.error.conf

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion src/notificationcategories/x-nemo.battery.conf
@@ -1,4 +1,4 @@
x-nemo-icon=icon-system-charging
app_icon=icon-system-charging
urgency=2
transient=true
x-nemo-feedback=charging_started
4 changes: 0 additions & 4 deletions src/notificationcategories/x-nemo.battery.enterpsm.conf

This file was deleted.

3 changes: 0 additions & 3 deletions src/notificationcategories/x-nemo.battery.exitpsm.conf

This file was deleted.

4 changes: 0 additions & 4 deletions src/notificationcategories/x-nemo.battery.lowbattery.conf

This file was deleted.

3 changes: 0 additions & 3 deletions src/notificationcategories/x-nemo.battery.notenoughpower.conf

This file was deleted.

4 changes: 0 additions & 4 deletions src/notificationcategories/x-nemo.battery.recharge.conf

This file was deleted.

3 changes: 0 additions & 3 deletions src/notificationcategories/x-nemo.battery.removecharger.conf

This file was deleted.

4 changes: 0 additions & 4 deletions src/notificationcategories/x-nemo.battery.shutdown.conf

This file was deleted.

4 changes: 0 additions & 4 deletions src/notificationcategories/x-nemo.battery.temperature.conf

This file was deleted.

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions src/notificationcategories/x-nemo.device.locked.conf

This file was deleted.

3 changes: 0 additions & 3 deletions src/notificationcategories/x-nemo.general.warning.conf

This file was deleted.

54 changes: 35 additions & 19 deletions src/notifications/batterynotifier.cpp
Expand Up @@ -396,45 +396,55 @@ void BatteryNotifier::sendNotification(BatteryNotifier::NotificationType type)
static const struct NotificationInfo {
QString category;
QString message;
QString feedback;
QString icon;
} description[] = {
{"x-nemo.battery", // NotificationCharging
//% "Charging"
qtTrId("qtn_ener_charging"),
"",
""},
{"x-nemo.battery.chargingcomplete", // NotificationChargingComplete
{"", // NotificationChargingComplete
//% "Charging complete"
qtTrId("qtn_ener_charcomp"),
""},
{"x-nemo.battery.removecharger", // NotificationRemoveCharger
"",
"icon-system-charging"},
{"", // NotificationRemoveCharger
//% "Disconnect charger from power supply to save energy"
qtTrId("qtn_ener_remcha"),
""},
{"x-nemo.battery.chargingnotstarted", // NotificationChargingNotStarted
"",
"icon-system-charging"},
{"", // NotificationChargingNotStarted
//% "Charging not started. Replace charger."
qtTrId("qtn_ener_repcharger"),
""},
{"x-nemo.battery.recharge", // NotificationRechargeBattery
"general_warning",
"icon-system-battery"},
{"", // NotificationRechargeBattery
//% "Recharge battery"
qtTrId("qtn_ener_rebatt"),
""},
{"x-nemo.battery.enterpsm", // NotificationEnteringPSM
"battery_empty",
"icon-system-battery"},
{"", // NotificationEnteringPSM
//% "Entering power save mode"
qtTrId("qtn_ener_ent_psnote"),
""},
{"x-nemo.battery.exitpsm", // NotificationExitingPSM
"battery_low",
"icon-system-battery"},
{"", // NotificationExitingPSM
//% "Exiting power save mode"
qtTrId("qtn_ener_exit_psnote"),
""},
{"x-nemo.battery.lowbattery", // NotificationLowBattery
"",
"icon-system-battery"},
{"", // NotificationLowBattery
//: Shown when the battery is low. %1 = current battery level as a percentage
//% "Low battery: %1%"
qtTrId("qtn_ener_lowbatt_with_percentage"),
""},
{"x-nemo.battery.notenoughpower", // NotificationNotEnoughPower
"battery_low",
"icon-system-battery"},
{"", // NotificationNotEnoughPower
//% "Not enough power to charge"
qtTrId("qtn_ener_nopowcharge"),
"icon-m-energy-management-insufficient-power"}
"",
"icon-system-battery"}
};
Q_ASSERT(type < sizeof(description) / sizeof(description[0]));
NotificationInfo const &info = description[type];
Expand All @@ -457,16 +467,22 @@ void BatteryNotifier::sendNotification(BatteryNotifier::NotificationType type)

/* Add fresh notification item */
QVariantHash hints;
hints.insert(LipstickNotification::HINT_CATEGORY, info.category);
hints.insert(LipstickNotification::HINT_PREVIEW_BODY, message);
if (!info.category.isEmpty()) {
hints.insert(LipstickNotification::HINT_CATEGORY, info.category);
}
if (!info.feedback.isEmpty()) {
hints.insert(LipstickNotification::HINT_FEEDBACK, info.feedback);
}
hints.insert(LipstickNotification::HINT_VISIBILITY, QLatin1String("public"));
hints.insert(LipstickNotification::HINT_URGENCY, LipstickNotification::Critical);
hints.insert(LipstickNotification::HINT_TRANSIENT, true);
QueuedNotification queuedNotification;
queuedNotification.m_type = type;
queuedNotification.m_id = m_notificationManager->Notify(m_notificationManager->systemApplicationName(),
0,
info.icon,
QString(),
QString(),
message,
QStringList(),
hints,
-1);
Expand Down

0 comments on commit 0cc2da9

Please sign in to comment.