Merge lp:~ahayzen/music-app/dynamic-recent-tab into lp:music-app/remix

Proposed by Andrew Hayzen
Status: Merged
Approved by: Victor Thompson
Approved revision: 802
Merged at revision: 799
Proposed branch: lp:~ahayzen/music-app/dynamic-recent-tab
Merge into: lp:music-app/remix
Diff against target: 363 lines (+100/-101)
4 files modified
LibraryListModel.qml (+2/-1)
meta-database.js (+9/-3)
music-app.qml (+70/-70)
po/com.ubuntu.music.pot (+19/-27)
To merge this branch: bzr merge lp:~ahayzen/music-app/dynamic-recent-tab
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Victor Thompson Approve
Review via email: mp+247071@code.launchpad.net

Commit message

* Only show the recent model if the recent model is not empty
* Remove unused models

Description of the change

* Only show the recent model if the recent model is not empty
* Remove unused models

TESTING
1) App remembers correct tab when there is not recent at startup
2) App remembers correct tab when there is recent at startup
3) App loads to recent page at startup (when closed on recent with data)
4) When there is no recent, select an album and play all adds recent to the tabs
5) When there is recent, selecting clear recent jumps you to the albums tab and removes recent from the tabs

Please test thoroughly :)

To post a comment you must log in.
798. By Andrew Hayzen

* Remove unused vars
* Update po/com.ubuntu.music.pot as there are UI string removals

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Victor Thompson (vthompson) wrote :

1. Could we update the copyright of LibraryListModel.qml to include 2015?
2. If the user has recent items, closes the app, then removes his Databases (~.local/share/com.ubuntu.music/Databases/*), the app still shows the Recent tab. When the user selects it, they are immediately brought to the Albums tab. Could we detect that there is no recent items at start up?

I still need to look at the code a bit more and do more testing. Pretty brilliant workaround though!

review: Needs Fixing
799. By Andrew Hayzen

* Add copyright year
* Fix for isRecentEmpty failing if the table doesn't exist

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
800. By Andrew Hayzen

* Merge of trunk

801. By Andrew Hayzen

* If the saved tabIndex is larger than the tab.count pick the last tab instead of recent || albums

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
802. By Andrew Hayzen

* Merge of trunk

Revision history for this message
Victor Thompson (vthompson) wrote :

LGTM! Love the fix for this, we might want to do an audit of existing Shorts bugs to see if they might have existing bugs for the dynamic tab implementation. Otherwise, I see no issues.

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'LibraryListModel.qml'
2--- LibraryListModel.qml 2014-10-27 18:34:26 +0000
3+++ LibraryListModel.qml 2015-01-21 01:16:53 +0000
4@@ -1,5 +1,5 @@
5 /*
6- * Copyright (C) 2013, 2014
7+ * Copyright (C) 2013, 2014, 2015
8 * Andrew Hayzen <ahayzen@gmail.com>
9 * Daniel Holm <d.holmen@gmail.com>
10 * Victor Thompson <victor.thompson@gmail.com>
11@@ -38,6 +38,7 @@
12 property alias preLoadComplete: worker.preLoadComplete
13 property alias syncFactor: worker.syncFactor
14 property alias workerComplete: worker.completed
15+ property alias workerList: worker.list
16
17 function get(index, role) {
18 return model.get(index);
19
20=== modified file 'meta-database.js'
21--- meta-database.js 2015-01-17 21:46:42 +0000
22+++ meta-database.js 2015-01-21 01:16:53 +0000
23@@ -321,9 +321,15 @@
24 var res = 0;
25
26 db.transaction(function(tx) {
27- var rs = tx.executeSql("SELECT count(*) as value FROM recent")
28-
29- if (rs.rows.item(0).value > 0) {
30+ var rs;
31+
32+ try {
33+ rs = tx.executeSql("SELECT count(*) as value FROM recent")
34+ } catch (e) {
35+ rs = null
36+ }
37+
38+ if (rs !== null && rs.rows.item(0).value > 0) {
39 res = rs.rows.item(0).value;
40 } else {
41 console.log("RECENT does not exist")
42
43=== modified file 'music-app.qml'
44--- music-app.qml 2015-01-21 00:40:26 +0000
45+++ music-app.qml 2015-01-21 01:16:53 +0000
46@@ -560,9 +560,10 @@
47 mainPageStack.push(tabs)
48
49 // if a tab index exists restore it, otherwise goto Recent if there are items otherwise go to Albums
50- tabs.selectedTabIndex = startupSettings.tabIndex === -1 || startupSettings.tabIndex > tabs.count - 1
51- ? (Library.isRecentEmpty() ? albumsTab.index : startTab.index)
52- : startupSettings.tabIndex
53+ tabs.selectedTabIndex = startupSettings.tabIndex === -1
54+ ? (Library.isRecentEmpty() ? albumsTab.index : 0)
55+ : (startupSettings.tabIndex > tabs.count - 1
56+ ? tabs.count - 1 : startupSettings.tabIndex)
57
58 loadedUI = true;
59
60@@ -859,22 +860,18 @@
61 if (preLoadComplete)
62 {
63 loading.visible = false
64- startTab.loading = false
65- startTab.populated = true
66+ recentTabRepeater.loading = false
67+ recentTabRepeater.populated = true
68+
69+ // Ensure any active tabs are insync as they use a copy of the repeater state
70+ for (var i=0; i < recentTabRepeater.count; i++) {
71+ recentTabRepeater.itemAt(i).loading = false
72+ recentTabRepeater.itemAt(i).populated = true
73+ }
74 }
75 }
76 }
77
78- // TODO: used by recent albums move to U1DB
79- LibraryListModel {
80- id: recentAlbumTracksModel
81- }
82-
83- // TODO: used by recent playlists move to U1DB
84- LibraryListModel {
85- id: recentPlaylistTracksModel
86- }
87-
88 // list of tracks on startup. This is just during development
89 LibraryListModel {
90 id: trackQueue
91@@ -1080,20 +1077,64 @@
92 }
93 }
94
95- // First tab is all music
96- Tab {
97+ // Use a repeater to 'hide' the recent tab when the model is empty
98+ // A repeater is used because the Tabs component respects adds and
99+ // removes. Whereas replacing the list tabChildren does not appear
100+ // to respect removes and setting the page as active: false causes
101+ // the page to be blank but the action to still in the overflow
102+ Repeater {
103+ id: recentTabRepeater
104+ // If the model has not loaded and at startup the db was not empty
105+ // then show recent or
106+ // If the workerlist has been set and it has values then show recent
107+ model: (!recentModel.preLoadComplete && !startupRecentEmpty) ||
108+ (recentModel.workerList !== undefined &&
109+ recentModel.workerList.length > 0) ? 1 : 0
110+ delegate: Component {
111+ // First tab is all music
112+ Tab {
113+ property bool populated: recentTabRepeater.populated
114+ property var loader: [recentModel.filterRecent]
115+ property bool loading: recentTabRepeater.loading
116+ property var model: [recentModel, albumTracksModel]
117+ id: startTab
118+ objectName: "startTab"
119+ anchors.fill: parent
120+ title: page.title
121+
122+ // Tab content begins here
123+ page: MusicStart {
124+ id: musicStartPage
125+ }
126+ }
127+ }
128+
129+ // Store the startup state of the db separately otherwise
130+ // it breaks the binding of model
131+ property bool startupRecentEmpty: Library.isRecentEmpty()
132+
133+ // cached values of the recent model that are copied when
134+ // the tab is created
135+ property bool loading: false
136 property bool populated: false
137- property var loader: [recentModel.filterRecent]
138- property bool loading: false
139- property var model: [recentModel, albumTracksModel]
140- id: startTab
141- objectName: "startTab"
142- anchors.fill: parent
143- title: page.title
144
145- // Tab content begins here
146- page: MusicStart {
147- id: musicStartPage
148+ onCountChanged: {
149+ if (count === 0 && loadedUI) {
150+ // Jump to the albums tab when recent is empty
151+ tabs.selectedTabIndex = albumsTab.index
152+ } else if (count > 0 && !loadedUI) {
153+ // UI is still loading and recent tab has been inserted
154+ // so move the selected index 'down' as the value is
155+ // not auto updated - this is for the case of loading
156+ // directly to the recent tab (otherwise the content
157+ // appears as the second tab but the tabs think they are
158+ // on the first tab)
159+ tabs.selectedTabIndex -= 1
160+ } else if (count > 0 && loadedUI) {
161+ // tab inserted while the app is running so move the
162+ // selected index 'up' to keep the same position
163+ tabs.selectedTabIndex += 1
164+ }
165 }
166 }
167
168@@ -1255,11 +1296,11 @@
169 Page {
170 id: emptyPage
171 title: i18n.tr("Music")
172- visible: (noMusic || noPlaylists || noRecent) && !firstRun
173+ visible: (noMusic || noPlaylists) && !firstRun
174
175 property bool noMusic: allSongsModel.rowCount === 0 && allSongsModelModel.status === SongsModel.Ready && loadedUI
176 property bool noPlaylists: playlistModel.model.count === 0 && playlistModel.workerComplete && mainPageStack.currentPage.title !== i18n.tr("Now playing") && mainPageStack.currentPage.title !== i18n.tr("Queue")
177- property bool noRecent: recentModel.model.count === 0 && recentModel.workerComplete && mainPageStack.currentPage.title !== i18n.tr("Now playing") && mainPageStack.currentPage.title !== i18n.tr("Queue")
178+
179 tools: ToolbarItems {
180 back: null
181 locked: true
182@@ -1400,47 +1441,6 @@
183 }
184 }
185 }
186-
187- // Overlay to show when no recent items are on the device
188- Rectangle {
189- id: recentEmpty
190- anchors {
191- fill: parent
192- topMargin: -emptyPage.header.height
193- }
194- color: mainView.backgroundColor
195- visible: emptyPage.noRecent && !emptyPage.noMusic && startTab.index === tabs.selectedTab.index
196-
197- Column {
198- anchors.centerIn: parent
199- spacing: units.gu(2)
200- width: parent.width
201-
202- Label {
203- color: styleMusic.libraryEmpty.labelColor
204- elide: Text.ElideRight
205- fontSize: "large"
206- font.bold: true
207- horizontalAlignment: Text.AlignHCenter
208- maximumLineCount: 2
209- text: i18n.tr("No recent albums or playlists found")
210- width: parent.width
211- wrapMode: Text.WordWrap
212- }
213-
214- Label {
215- color: styleMusic.libraryEmpty.labelColor
216- elide: Text.ElideRight
217- fontSize: "medium"
218- horizontalAlignment: Text.AlignHCenter
219- maximumLineCount: 2
220- text: i18n.tr("Play some music to see your favorites")
221- width: parent.width
222- wrapMode: Text.WordWrap
223- }
224- }
225- }
226-
227 }
228
229 LoadingSpinnerComponent {
230
231=== modified file 'po/com.ubuntu.music.pot'
232--- po/com.ubuntu.music.pot 2015-01-21 00:40:26 +0000
233+++ po/com.ubuntu.music.pot 2015-01-21 01:16:53 +0000
234@@ -8,7 +8,7 @@
235 msgstr ""
236 "Project-Id-Version: music-app\n"
237 "Report-Msgid-Bugs-To: \n"
238-"POT-Creation-Date: 2015-01-21 00:40+0000\n"
239+"POT-Creation-Date: 2015-01-21 01:16+0000\n"
240 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
241 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
242 "Language-Team: LANGUAGE <LL@li.org>\n"
243@@ -56,14 +56,14 @@
244 msgid "Genre"
245 msgstr ""
246
247-#: ../MusicNowPlaying.qml:35 ../music-app.qml:667 ../music-app.qml:699
248-#: ../music-app.qml:1062 ../music-app.qml:1221 ../music-app.qml:1233
249-#: ../music-app.qml:1261 ../music-app.qml:1262
250+#: ../MusicNowPlaying.qml:35 ../music-app.qml:668 ../music-app.qml:700
251+#: ../music-app.qml:1059 ../music-app.qml:1262 ../music-app.qml:1274
252+#: ../music-app.qml:1302
253 msgid "Queue"
254 msgstr ""
255
256-#: ../MusicNowPlaying.qml:35 ../music-app.qml:667 ../music-app.qml:1061
257-#: ../music-app.qml:1220 ../music-app.qml:1261 ../music-app.qml:1262
258+#: ../MusicNowPlaying.qml:35 ../music-app.qml:668 ../music-app.qml:1058
259+#: ../music-app.qml:1261 ../music-app.qml:1302
260 msgid "Now playing"
261 msgstr ""
262
263@@ -131,7 +131,7 @@
264 msgid "Add to queue"
265 msgstr ""
266
267-#: ../MusicaddtoPlaylist.qml:42 ../music-app.qml:1373
268+#: ../MusicaddtoPlaylist.qml:42 ../music-app.qml:1414
269 msgid "Select playlist"
270 msgstr ""
271
272@@ -179,7 +179,7 @@
273 msgid "Rename playlist"
274 msgstr ""
275
276-#: ../common/SongsPage.qml:528 ../music-app.qml:1015
277+#: ../common/SongsPage.qml:528 ../music-app.qml:1012
278 msgid "Enter playlist name"
279 msgstr ""
280
281@@ -187,16 +187,16 @@
282 msgid "Change"
283 msgstr ""
284
285-#: ../common/SongsPage.qml:558 ../music-app.qml:1041
286+#: ../common/SongsPage.qml:558 ../music-app.qml:1038
287 msgid "Playlist already exists"
288 msgstr ""
289
290-#: ../common/SongsPage.qml:562 ../music-app.qml:1046
291+#: ../common/SongsPage.qml:562 ../music-app.qml:1043
292 msgid "Please type in a name."
293 msgstr ""
294
295 #: ../common/SongsPage.qml:567 ../common/SongsPage.qml:605
296-#: ../music-app.qml:485 ../music-app.qml:1052
297+#: ../music-app.qml:485 ../music-app.qml:1049
298 msgid "Cancel"
299 msgstr ""
300
301@@ -223,7 +223,7 @@
302 msgid "Import your music"
303 msgstr ""
304
305-#: ../common/Walkthrough/Slide2.qml:62 ../music-app.qml:1358
306+#: ../common/Walkthrough/Slide2.qml:62 ../music-app.qml:1399
307 msgid ""
308 "Connect your device to any computer and simply drag files to the Music "
309 "folder or insert removable media with music."
310@@ -333,46 +333,38 @@
311 msgid "No songs played today"
312 msgstr ""
313
314-#: ../music-app.qml:589 ../music-app.qml:1257
315+#: ../music-app.qml:590 ../music-app.qml:1298
316 #: com.ubuntu.music_music.desktop.in.in.h:1
317 msgid "Music"
318 msgstr ""
319
320-#: ../music-app.qml:608
321+#: ../music-app.qml:609
322 msgid "Debug: "
323 msgstr ""
324
325-#: ../music-app.qml:1011
326+#: ../music-app.qml:1008
327 msgid "New playlist"
328 msgstr ""
329
330-#: ../music-app.qml:1025
331+#: ../music-app.qml:1022
332 msgid "Create"
333 msgstr ""
334
335-#: ../music-app.qml:1347
336+#: ../music-app.qml:1388
337 msgid "No music found"
338 msgstr ""
339
340-#: ../music-app.qml:1386
341+#: ../music-app.qml:1427
342 msgid "No playlists found"
343 msgstr ""
344
345-#: ../music-app.qml:1397
346+#: ../music-app.qml:1438
347 #, qt-format
348 msgid ""
349 "Get more out of Music by tapping the %1 icon to start making playlists for "
350 "every mood and occasion."
351 msgstr ""
352
353-#: ../music-app.qml:1426
354-msgid "No recent albums or playlists found"
355-msgstr ""
356-
357-#: ../music-app.qml:1437
358-msgid "Play some music to see your favorites"
359-msgstr ""
360-
361 #: com.ubuntu.music_music.desktop.in.in.h:2
362 msgid "A music application for Ubuntu"
363 msgstr ""

Subscribers

People subscribed via source and target branches