on xenial help sign in
Reject quick drags on the panel menu

Very quick drags could cause the panel to call out to launch the dialer during a phone call, which is generally not helpful when you're trying to drag the indicators down quickly. Fixes https://github.com/ubports/ubuntu-touch/issues/1198

commit0070dd4cccbd2b77a62a3ca8b9173647f0997709 authorDalton Durst <dalton@ubports.com> dateWed 2 Oct 2019, 20:29 (7 years ago) parent8b85462
2 files changed+27−1
qml/Panel/PanelMenu.qml+3−1 tests/qmltests/Panel/tst_PanelMenu.qml+24
qml/Panel/PanelMenu.qml+3−1
@@ -49,6 +49,8 @@ Showable {
4949 readonly property int barWidth: adjustDragHandleSizeToContents ? Math.min(bar.width, bar.implicitWidth) : bar.width
5050 readonly property alias currentMenuIndex: bar.currentItemIndex
5151
52+ // The user tapped the panel and did not move.
53+ // Note that this does not fire on mouse events, only touch events.
5254 signal showTapped()
5355
5456 // TODO: Perhaps we need a animation standard for showing/hiding? Each showable seems to
@@ -242,7 +244,7 @@ Showable {
242244 touchPressTime = new Date().getTime();
243245 } else {
244246 var touchReleaseTime = new Date().getTime();
245− if (touchReleaseTime - touchPressTime <= 300) {
247+ if (touchReleaseTime - touchPressTime <= 300 && distance < units.gu(1)) {
246248 root.showTapped();
247249 }
248250 }
tests/qmltests/Panel/tst_PanelMenu.qml+24
@@ -31,6 +31,12 @@ PanelTest {
3131 target: clickThroughTester
3232 }
3333
34+ SignalSpy {
35+ id: showTappedSpy
36+ target: indicatorsMenu
37+ signalName: "showTapped"
38+ }
39+
3440 MouseArea {
3541 id: clickThroughTester
3642 anchors.fill: root
@@ -140,6 +146,7 @@ PanelTest {
140146
141147 function cleanup() {
142148 clickThroughSpy.clear();
149+ showTappedSpy.clear();
143150 }
144151
145152 function get_indicator_item(index) {
@@ -321,5 +328,22 @@ PanelTest {
321328 indicatorsMenu.available = true;
322329 indicatorsMenu.hide();
323330 }
331+
332+ // Ensure that showTapped is only signaled when the user hasn't moved
333+ // thir tap point
334+ // Prior to this, the user could press and drag down very fast but
335+ // still call showTapped
336+ function test_showTapped() {
337+ // Get the first indicator
338+ var firstItem = get_indicator_item(0);
339+ var firstItemMappedPosition = indicatorsMenu.mapFromItem(firstItem, firstItem.width/2, firstItem.height/2);
340+
341+ touchFlick(indicatorsMenu,
342+ firstItemMappedPosition.x, indicatorsMenu.minimizedPanelHeight / 2,
343+ firstItemMappedPosition.x, indicatorsMenu.minimizedPanelHeight * 7,
344+ true /* beginTouch */, true /* endTouch */, 100, 2);
345+
346+ verify(showTappedSpy.count === 0);
347+ }
324348 }
325349}