on xenial help sign in
Implemented feature-request from Design for modal snap-decision notifications on the phone. See LP #1285712 Fixes: 1285712
5c25f78Mirco Müller
debian/control+1−1
@@ -102,7 +102,7 @@ Depends: qtdeclarative5-ubuntu-thumbnailer0.1 | ubuntu-thumbnailer-impl,
102 qtdeclarative5-unity-notifications-plugin | unity-notifications-impl,
102 qtdeclarative5-unity-notifications-plugin | unity-notifications-impl,
103 ubuntu-thumbnailer-impl-0,
103 ubuntu-thumbnailer-impl-0,
104 unity-application-impl-2,
104 unity-application-impl-2,
105− unity-notifications-impl-2,
105+ unity-notifications-impl-3,
106 unity-plugin-scopes | unity-scopes-impl,
106 unity-plugin-scopes | unity-scopes-impl,
107 unity-scopes-impl-0,
107 unity-scopes-impl-0,
108 unity8-fake-env | unity-application-impl,
108 unity8-fake-env | unity-application-impl,
qml/Notifications/Notifications.qml+11
@@ -16,6 +16,8 @@
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18import Ubuntu.Components 0.1
18import Ubuntu.Components 0.1
19+import Unity.Notifications 1.0 as UnityNotifications
20+import Utils 0.1
19import "../Components"
21import "../Components"
20
22
21ListView {
23ListView {
@@ -25,6 +27,15 @@ ListView {
25 interactive: false
27 interactive: false
26
28
27 property real margin
29 property real margin
30+ property bool useModal: snapDecisionProxyModel.count > 0
31+
32+ SortFilterProxyModel {
33+ id: snapDecisionProxyModel
34+
35+ model: notificationList.model
36+ filterRole: UnityNotifications.ModelInterface.RoleType
37+ filterRegExp: RegExp(UnityNotifications.Notification.SnapDecision)
38+ }
28 spacing: delegate.fullscreen ? 0 : units.gu(.5)
39 spacing: delegate.fullscreen ? 0 : units.gu(.5)
29
40
30 currentIndex: (currentIndex < 1 && count > 1) ? 1 : -1
41 currentIndex: (currentIndex < 1 && count > 1) ? 1 : -1
qml/Shell.qml+18
@@ -582,6 +582,24 @@ FocusScope {
582 }
582 }
583 }
583 }
584
584
585+ Rectangle {
586+ id: modalNotificationBackground
587+
588+ visible: notifications.useModal && !greeter.shown && (notifications.state == "narrow")
589+ color: "#000000"
590+ anchors.fill: parent
591+ opacity: 0.5
592+
593+ MouseArea {
594+ anchors.fill: parent
595+ }
596+
597+ InputFilterArea {
598+ anchors.fill: parent
599+ blockInput: modalNotificationBackground.visible
600+ }
601+ }
602+
585 Notifications {
603 Notifications {
586 id: notifications
604 id: notifications
587
605
tests/autopilot/unity8/shell/tests/test_notifications.py+83
@@ -211,6 +211,89 @@ class InteractiveNotificationBase(NotificationsBase):
211 self.touch.tap_object(notification.select_single(objectName="button4"))
211 self.touch.tap_object(notification.select_single(objectName="button4"))
212 self.assert_notification_action_id_was_called("action_decline_4")
212 self.assert_notification_action_id_was_called("action_decline_4")
213
213
214+ def test_modal_sd_without_greeter (self):
215+ """A snap-decision on a phone should block input to shell beneath it when there's no greeter."""
216+ unity_proxy = self.launch_unity()
217+ unlock_unity(unity_proxy)
218+
219+ summary = "Incoming file"
220+ body = "Frank would like to send you the file: essay.pdf"
221+ icon_path = "sync-idle"
222+ hints = [
223+ ("x-canonical-snap-decisions", "true"),
224+ ("x-canonical-non-shaped-icon", "true"),
225+ ]
226+
227+ actions = [
228+ ('action_accept', 'Accept'),
229+ ('action_decline_1', 'Decline'),
230+ ]
231+
232+ self._create_interactive_notification(
233+ summary,
234+ body,
235+ icon_path,
236+ "NORMAL",
237+ actions,
238+ hints
239+ )
240+
241+ # verify that we cannot reveal the launcher (no longer interact with the shell)
242+ time.sleep(1)
243+ self.main_window.show_dash_swiping()
244+ launcher = self.main_window.get_launcher()
245+ self.assertThat(launcher.shown, Eventually(Equals(False)))
246+
247+ # verify and interact with the triggered snap-decision notification
248+ notify_list = self._get_notifications_list()
249+ get_notification = lambda: notify_list.wait_select_single(
250+ 'Notification', objectName='notification1')
251+ notification = get_notification()
252+ self._assert_notification(notification, summary, body, True, False, 1.0)
253+ self.touch.tap_object(notification.select_single(objectName="button0"))
254+ self.assert_notification_action_id_was_called("action_accept")
255+
256+ def test_modal_sd_with_greeter (self):
257+ """A snap-decision on a phone should not block input to the greeter beneath it."""
258+ unity_proxy = self.launch_unity()
259+
260+ summary = "Incoming file"
261+ body = "Frank would like to send you the file: essay.pdf"
262+ icon_path = "sync-idle"
263+ hints = [
264+ ("x-canonical-snap-decisions", "true"),
265+ ("x-canonical-non-shaped-icon", "true"),
266+ ]
267+
268+ actions = [
269+ ('action_accept', 'Accept'),
270+ ('action_decline_1', 'Decline'),
271+ ]
272+
273+ self._create_interactive_notification(
274+ summary,
275+ body,
276+ icon_path,
277+ "NORMAL",
278+ actions,
279+ hints
280+ )
281+
282+ # verify that we can swipe away the greeter (interact with the "shell")
283+ time.sleep(1)
284+ self.main_window.show_dash_swiping()
285+ greeter = self.main_window.get_greeter()
286+ self.assertThat(greeter.shown, Eventually(Equals(False)))
287+
288+ # verify and interact with the triggered snap-decision notification
289+ notify_list = self._get_notifications_list()
290+ get_notification = lambda: notify_list.wait_select_single(
291+ 'Notification', objectName='notification1')
292+ notification = get_notification()
293+ self._assert_notification(notification, summary, body, True, False, 1.0)
294+ self.touch.tap_object(notification.select_single(objectName="button0"))
295+ self.assert_notification_action_id_was_called("action_accept")
296+
214 def _create_interactive_notification(
297 def _create_interactive_notification(
215 self,
298 self,
216 summary="",
299 summary="",