Merge lp:~phablet-team/gallery-app/share-from-selection into lp:gallery-app

Proposed by Ugo Riboni
Status: Merged
Approved by: Bill Filler
Approved revision: 1068
Merged at revision: 1079
Proposed branch: lp:~phablet-team/gallery-app/share-from-selection
Merge into: lp:gallery-app
Diff against target: 281 lines (+142/-4)
8 files modified
rc/qml/EventsOverview.qml (+47/-0)
rc/qml/MediaViewer/MediaViewer.qml (+1/-1)
rc/qml/PhotosOverview.qml (+45/-0)
rc/qml/Utility/SelectionState.qml (+31/-0)
rc/qml/Utility/SelectionToolbarAction.qml (+1/-1)
src/qml/qml-view-collection-model.cpp (+12/-0)
src/qml/qml-view-collection-model.h (+3/-0)
tests/autopilot/gallery_app/emulators/photo_viewer.py (+2/-2)
To merge this branch: bzr merge lp:~phablet-team/gallery-app/share-from-selection
Reviewer Review Type Date Requested Status
Bill Filler (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+234215@code.launchpad.net

Commit message

Allow sharing from the events or photo view, while selecting.

Description of the change

Allow sharing from the events or photo view, while selecting.

Currently no application knows how to handle shares of multiple media. However the share peer picker displays these apps anyway (facebook and messaging) when there is multiple media selected, and going into these apps will give broken behaviour.
For this reason currently the share button is only enabled when there's one single item selected. This should be fixed in the content hub by allowing apps to declare if they can handle multiple selections or not.

Additionally the share button in the header does not visually show as disabled, even though it is, this is due to a bug in the SDK: https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1369640

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1060. By Ugo Riboni

Hide the header when launching the share picker. Correctly count selected medias.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1061. By Ugo Riboni

Fix naming object naming to prevent existing tests from failing

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1062. By Ugo Riboni

Change the share photo message to a generic share because we could be sharing a video too

Revision history for this message
Bill Filler (bfiller) wrote :

2 issues:
1) screen totally white on gallery-app after returning from share
2) AP test is failing, see above

review: Needs Fixing
Revision history for this message
Bill Filler (bfiller) wrote :

Another issue:
I see the header stay visible if it was previously turned on, meaning: 1) from events view open a photo and click on it to reveal the header 2) press back button 3) select a photo and share. Then header incorrectly visible on pick screen

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1063. By Ugo Riboni

Temporarily merge qtcompat branch

1064. By Ugo Riboni

More properly fix test

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1065. By Ugo Riboni

Fix incorrect calculation of media types and total media

1066. By Ugo Riboni

Hide and show the ContentPeerPicker more properly

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
1067. By Ugo Riboni

Merge changes from trunk

1068. By Ugo Riboni

Make sure header is hidden even when sharing after coming back from photo viewer

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Bill Filler (bfiller) wrote :

tested, approved
Did you perform an exploratory manual test run of the code change and any related functionality on device or emulator?
yes

Did you successfully run all tests found in your component's Test Plan (https://wiki.ubuntu.com/Process/Merges/TestPlan/<package-name>) on device or emulator?
yes

Did CI run pass? If not, please explain why.
yes

Have you checked that submitter has accurately filled out the submitter checklist and has taken no shortcut?
yes

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'rc/qml/EventsOverview.qml'
2--- rc/qml/EventsOverview.qml 2014-09-17 16:59:32 +0000
3+++ rc/qml/EventsOverview.qml 2014-09-22 14:10:21 +0000
4@@ -18,6 +18,7 @@
5 import Ubuntu.Components 0.1
6 import Ubuntu.Components.Popups 0.1
7 import Gallery 1.0
8+import Ubuntu.Content 0.1
9 import "Components"
10 import "OrganicView"
11 import "Utility"
12@@ -99,8 +100,54 @@
13 onDeleteClicked: {
14 PopupUtils.open(deleteDialog, null);
15 }
16+
17+ onShareClicked: {
18+ overview.pushPage(sharePicker);
19+ sharePicker.visible = true;
20+ }
21 }
22
23 property bool selectionMode: selection.inSelectionMode
24 tools: selectionMode ? selectionTools : overviewTools
25+
26+ Component {
27+ id: contentItemComp
28+ ContentItem {}
29+ }
30+
31+ Page {
32+ id: sharePicker
33+ visible: false
34+ title: i18n.tr("Share to")
35+
36+ ContentPeerPicker {
37+ objectName: "sharePickerEvents"
38+ anchors.fill: parent
39+ showTitle: false
40+
41+ contentType: organicEventView.selection.mediaType === MediaSource.Video ? ContentType.Videos : ContentType.Pictures
42+ handler: ContentHandler.Share
43+
44+ onPeerSelected: {
45+ overview.popPage();
46+ sharePicker.visible = false;
47+
48+ var curTransfer = peer.request();
49+ if (curTransfer.state === ContentTransfer.InProgress)
50+ {
51+ var medias = organicEventView.selection.model.selectedMediasQML;
52+ curTransfer.items = medias.filter(function(data) {
53+ return data.hasOwnProperty('type'); // filter out event headers
54+ }).map(function(data) {
55+ return contentItemComp.createObject(parent, {"url": data.path});
56+ });
57+ curTransfer.state = ContentTransfer.Charged;
58+ }
59+ }
60+ onCancelPressed: {
61+ overview.popPage();
62+ sharePicker.visible = false;
63+ }
64+ }
65+ }
66 }
67
68=== modified file 'rc/qml/MediaViewer/MediaViewer.qml'
69--- rc/qml/MediaViewer/MediaViewer.qml 2014-09-03 00:14:45 +0000
70+++ rc/qml/MediaViewer/MediaViewer.qml 2014-09-22 14:10:21 +0000
71@@ -499,7 +499,7 @@
72 },
73 Action {
74 objectName: "shareButton"
75- text: i18n.tr("Share photo")
76+ text: i18n.tr("Share")
77 iconName: "share"
78 visible: !APP.desktopMode
79 onTriggered: sharePicker.visible = true;
80
81=== modified file 'rc/qml/PhotosOverview.qml'
82--- rc/qml/PhotosOverview.qml 2014-09-17 16:59:32 +0000
83+++ rc/qml/PhotosOverview.qml 2014-09-22 14:10:21 +0000
84@@ -21,6 +21,7 @@
85 import Gallery 1.0
86 import Ubuntu.Components 0.1
87 import Ubuntu.Components.Popups 0.1
88+import Ubuntu.Content 0.1
89 import "Components"
90 import "OrganicView"
91 import "Utility"
92@@ -50,6 +51,8 @@
93 d.selection.inSelectionMode = false;
94 }
95
96+ property string pageTitle
97+
98 tools: inSelectionMode ? d.selectionTools : d.overviewTools
99
100 Image {
101@@ -114,6 +117,48 @@
102 onDeleteClicked: {
103 PopupUtils.open(deleteDialog, null);
104 }
105+
106+ onShareClicked: {
107+ overview.pushPage(sharePicker)
108+ sharePicker.visible = true;
109+ }
110+ }
111+ }
112+
113+ Component {
114+ id: contentItemComp
115+ ContentItem {}
116+ }
117+
118+ Page {
119+ id: sharePicker
120+ visible: false
121+ title: i18n.tr("Share to")
122+
123+ ContentPeerPicker {
124+ objectName: "sharePickerPhotos"
125+ showTitle: false
126+ anchors.fill: parent
127+ contentType: d.selection.mediaType === MediaSource.Video ? ContentType.Videos : ContentType.Pictures
128+ handler: ContentHandler.Share
129+
130+ onPeerSelected: {
131+ overview.popPage();
132+ sharePicker.visible = false;
133+
134+ var curTransfer = peer.request();
135+ if (curTransfer.state === ContentTransfer.InProgress)
136+ {
137+ curTransfer.items = d.selection.model.selectedMediasQML.map(function(data) {
138+ return contentItemComp.createObject(parent, {"url": data.path});
139+ });
140+ curTransfer.state = ContentTransfer.Charged;
141+ }
142+ }
143+ onCancelPressed: {
144+ overview.popPage();
145+ sharePicker.visible = false;
146+ }
147 }
148 }
149 }
150
151=== modified file 'rc/qml/Utility/SelectionState.qml'
152--- rc/qml/Utility/SelectionState.qml 2013-06-26 08:59:08 +0000
153+++ rc/qml/Utility/SelectionState.qml 2014-09-22 14:10:21 +0000
154@@ -31,6 +31,12 @@
155 property bool allowSelectionModeChange: true
156 /// It true, only one item can be selected
157 property bool singleSelect: false
158+ /// If true, a mix of videos and pictures is selected.
159+ /// Should be ignored if only one item is selected.
160+ property bool isMixed: false
161+ /// The type of all the selected media.
162+ /// Should be ignored if isMixed is true.
163+ property var mediaType
164
165 /*!
166 */
167@@ -38,10 +44,35 @@
168 monitored: true
169 }
170
171+ Connections {
172+ target: model
173+ onSelectionChanged: {
174+ var data = model.selectedMediasQML;
175+ var photos = 0;
176+ var videos = 0;
177+ var medias = 0;
178+
179+ for (var i in data) {
180+ if (data[i].hasOwnProperty('type')) {
181+ medias++;
182+ (data[i].type === MediaSource.Photo) ? photos++ : videos++;
183+ }
184+ }
185+
186+ organicSelectionState.mediaType = (photos > videos) ? MediaSource.Photo : MediaSource.Video;
187+ organicSelectionState.isMixed = (photos > 0 && videos > 0);
188+ organicSelectionState.selectedMediaCount = medias;
189+ }
190+ }
191+
192 // readonly
193 /// The number of currently selected items
194 property int selectedCount: model.selectedCount
195
196+ // readonly
197+ /// The number of currently selected media items
198+ property int selectedMediaCount: 0
199+
200 //internal
201 // HACK: this is used as a spurious extra QML condition in our isSelected
202 // check so we can cause the function to be reevaluated whenever the
203
204=== modified file 'rc/qml/Utility/SelectionToolbarAction.qml'
205--- rc/qml/Utility/SelectionToolbarAction.qml 2014-08-31 09:22:54 +0000
206+++ rc/qml/Utility/SelectionToolbarAction.qml 2014-09-22 14:10:21 +0000
207@@ -64,7 +64,7 @@
208 objectName: "shareButton"
209 text: i18n.tr("Share")
210 iconName: "share"
211- enabled: root.selection.selectedCount > 0
212+ enabled: root.selection.selectedMediaCount == 1
213 onTriggered: root.shareClicked();
214 }
215 }
216
217=== modified file 'src/qml/qml-view-collection-model.cpp'
218--- src/qml/qml-view-collection-model.cpp 2014-08-20 18:37:06 +0000
219+++ src/qml/qml-view-collection-model.cpp 2014-09-22 14:10:21 +0000
220@@ -413,6 +413,18 @@
221 return selectedList;
222 }
223
224+QVariantList QmlViewCollectionModel::selectedMediasQML() const
225+{
226+ QVariantList selectedList;
227+ QSet<DataObject*> totalSelection = m_view->getSelected();
228+ foreach (DataObject* data, totalSelection) {
229+ QVariant var;
230+ var.setValue(data);
231+ selectedList << var;
232+ }
233+ return selectedList;
234+}
235+
236 /*!
237 * \brief QmlViewCollectionModel::setBackingViewCollection
238 * \param view
239
240=== modified file 'src/qml/qml-view-collection-model.h'
241--- src/qml/qml-view-collection-model.h 2014-08-19 08:28:09 +0000
242+++ src/qml/qml-view-collection-model.h 2014-09-22 14:10:21 +0000
243@@ -26,6 +26,7 @@
244 #include <QList>
245 #include <QModelIndex>
246 #include <QVariant>
247+#include <QVariantList>
248
249 // core
250 #include <data-collection.h>
251@@ -48,6 +49,7 @@
252 Q_PROPERTY(int selectedCount READ selectedCount NOTIFY selectedCountChanged)
253 // not for use in QML directly, but QML can use it, to pass it as QVariant back to C++
254 Q_PROPERTY(QList<MediaSource*> selectedMedias READ selectedMedias NOTIFY selectionChanged)
255+ Q_PROPERTY(QVariantList selectedMediasQML READ selectedMediasQML NOTIFY selectionChanged)
256 Q_PROPERTY(QVariant forCollection READ forCollection WRITE setForCollection
257 NOTIFY backingCollectionChanged)
258 Q_PROPERTY(QVariant monitorSelection READ monitorSelection
259@@ -119,6 +121,7 @@
260 void setMediaTypeFilter(MediaSource::MediaType mediaTypeFilter);
261
262 QList<MediaSource*> selectedMedias() const;
263+ QVariantList selectedMediasQML() const;
264
265 SelectableViewCollection* backingViewCollection() const;
266
267
268=== modified file 'tests/autopilot/gallery_app/emulators/photo_viewer.py'
269--- tests/autopilot/gallery_app/emulators/photo_viewer.py 2014-09-03 00:14:45 +0000
270+++ tests/autopilot/gallery_app/emulators/photo_viewer.py 2014-09-22 14:10:21 +0000
271@@ -31,8 +31,8 @@
272
273 def get_content_peer_picker_cancel_button(self):
274 """Returns the ContentPeerPicker cancel button."""
275- return self.app.wait_select_single("Button",
276- objectName="contentPeerPickerCancelButton")
277+ return self.get_share_peer_picker().wait_select_single("Button",
278+ objectName="contentPeerPickerCancelButton")
279
280 def get_share_peer_picker(self):
281 """Returns the photo viewer share picker."""

Subscribers

People subscribed via source and target branches

to all changes: