on xenial help sign in
- Remove "Reviews and Comments" section from Application Preview until the feature is ready (BUG: #1226632)

- Detect when the keyboard is being shown to allow the user to scroll the Preview even more if necessary to interact with the components at the bottom of that preview, and don't leave those components obscured behind the keyboard (BUG: #1226638). Fixes: https://bugs.launchpad.net/bugs/1224717, https://bugs.launchpad.net/bugs/1226632, https://bugs.launchpad.net/bugs/1226638. Approved by PS Jenkins bot, Michał Sawicz, Alejandro J. Cura.

commitf82055e220c59aaaa9972cebdb2e59fcbfd16965 authorDiego Sarmentero <diego.sarmentero@gmail.com> dateThu 26 Sep 2013, 21:36 (13 years ago) parent81f0882e2838ee
4 files changed+45
Dash/Apps/AppPreview.qml+7 Dash/Apps/AppReviews.qml+3 Dash/DashPreview.qml+13 tests/qmltests/Dash/Apps/tst_AppPreview.qml+22
Dash/Apps/AppPreview.qml+7
@@ -191,12 +191,19 @@ DashPreview {
191191 ListItem.ThinDivider { }
192192
193193 AppReviews {
194+ id: appReviews
194195 objectName: "appReviews"
196+ // TODO: This should make this visible when the feature for reviews/comments is complete.
197+ visible: false
195198 anchors { left: parent.left; right: parent.right }
196199
197200 model: root.previewData.infoMap["comments"] ? root.previewData.infoMap["comments"].value : undefined
198201
199202 onSendReview: root.sendUserReview(review);
203+
204+ onEditing: {
205+ root.ensureVisible(appReviews.textArea);
206+ }
200207 }
201208 }
202209 }
Dash/Apps/AppReviews.qml+3
@@ -23,8 +23,10 @@ Column {
2323 id: root
2424
2525 property var model
26+ property alias textArea: reviewField
2627
2728 signal sendReview(string review)
29+ signal editing
2830
2931 spacing: units.gu(2)
3032 state: ""
@@ -93,6 +95,7 @@ Column {
9395 if(reviewField.focus){
9496 root.state = "editing";
9597 reviewField.selectAll();
98+ root.editing();
9699 }
97100 }
98101
Dash/DashPreview.qml+13
@@ -20,6 +20,7 @@ import Ubuntu.Components 0.1
2020Rectangle {
2121 id: root
2222
23+ property int keyboardSize: Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height : 0
2324 property var previewData
2425
2526 property string title: ""
@@ -38,6 +39,14 @@ Rectangle {
3839 color: Qt.rgba(0, 0, 0, .3)
3940 clip: true
4041
42+ function ensureVisible(item) {
43+ var o = leftFlickable.mapFromItem(item, 0, 0, item.width, item.height);
44+ var keyboardY = shell.height - root.keyboardSize;
45+ if ((o.y + o.height) > keyboardY) {
46+ leftFlickable.contentY += o.y + o.height - keyboardY;
47+ }
48+ }
49+
4150 Connections {
4251 target: shell.applicationManager
4352 onMainStageFocusedApplicationChanged: {
@@ -128,12 +137,16 @@ Rectangle {
128137
129138 Flickable {
130139 id: leftFlickable
140+ objectName: "leftFlickable"
131141 anchors.top: parent.top
132142 anchors.bottom: parent.bottom
133143 width: root.narrowMode ? contentRow.width : contentRow.width * root.previewWidthRatio
134144 contentHeight: leftColumn.height
145+ anchors.bottomMargin: root.keyboardSize
135146 clip: true
136147
148+ Behavior on contentY { NumberAnimation { duration: 300 } }
149+
137150 Column {
138151 id: leftColumn
139152 objectName: "leftColumn"
tests/qmltests/Dash/Apps/tst_AppPreview.qml+22
@@ -25,6 +25,9 @@ Item {
2525 width: units.gu(60)
2626 height: units.gu(80)
2727
28+ // Fake shell
29+ QtObject { id: shell; property int height: appPreview.height }
30+
2831 property var calls: []
2932
3033 SignalSpy {
@@ -114,6 +117,9 @@ Item {
114117 reviewField.text = "";
115118 data.rating = rating.value;
116119 dataProgress.infoMap["progressbar_source"].value = "service";
120+ var appReviews = findChild(appPreview, "appReviews");
121+ appReviews.visible = false;
122+ appPreview.keyboardSize = 0;
117123 }
118124
119125 function test_actions() {
@@ -149,6 +155,7 @@ Item {
149155
150156 function test_review_focus() {
151157 var appReviews = findChild(appPreview, "appReviews");
158+ appReviews.visible = true;
152159 var sendButton = findChild(appReviews, "sendButton");
153160 var reviewField = findChild(appReviews, "reviewField");
154161
@@ -213,5 +220,20 @@ Item {
213220 compare(root.calls[0][1], {"error": "DOWNLOAD ERROR"}, "Data of action not found.");
214221 }
215222
223+ function test_automatic_scroll_on_keyboard_shown() {
224+ waitForRendering(appPreview);
225+ var appReviews = findChild(appPreview, "appReviews");
226+ appReviews.visible = true;
227+
228+ var leftFlickable = findChild(appPreview, "leftFlickable");
229+ leftFlickable.contentY = leftFlickable.contentHeight;
230+ var reviewField = findChild(appReviews, "reviewField");
231+ appPreview.keyboardSize = 400;
232+ appReviews.editing(reviewField);
233+ var newFlickPos = leftFlickable.contentY;
234+ var keyboardY = shell.height - appPreview.keyboardSize;
235+ verify(newFlickPos < keyboardY);
236+ }
237+
216238 }
217239}