← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~ahayzen/music-app/fix-1357324-content-hub-source into lp:music-app

 

Andrew Hayzen has proposed merging lp:~ahayzen/music-app/fix-1357324-content-hub-source into lp:music-app.

Commit message:
* Add support for a content-hub source in both single and multiple selection modes

Requested reviews:
  Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot): continuous-integration
  Music App Developers (music-app-dev)
Related bugs:
  Bug #1357324 in Ubuntu Music App: "Content hub integration as source of music"
  https://bugs.launchpad.net/music-app/+bug/1357324

For more details, see:
https://code.launchpad.net/~ahayzen/music-app/fix-1357324-content-hub-source/+merge/268391

* Add support for a content-hub source in both single and multiple selection modes

TESTING:
Install the test importer:
bzr branch lp:~ahayzen/+junk/hub-importer-music-patches 
cd hub-importer-music-patches
click build .
adb push *.click /tmp/my.click
adb shell pkcon install-local --allow-untrusted /tmp/my.click

Install the new music app (if it has the same rev restart the device as the new apparmor profile won't be refreshed)

Open the hub-importer, select "Import contacts" then Music. When in singular mode only 1 track can be selected and imported and when in multiple many tracks can be selected. The X should cancel the import. You can change the selection type from singular to multiple here [0].

Test with the app both open and closed beforehand (if it is closed the app will close after the transfer is complete [there is a bug in the shell which sometimes means it remains shown in the spread when it has actually quit] if it is open it will remain open).

Notes:
If the app is started by an import for the first time, should it show the walkthrough? If it is not to show the walkthrough we need to ensure that the current code cannot by layered incorrectly.

0 - http://bazaar.launchpad.net/~ahayzen/+junk/hub-importer-music-patches/view/head:/hub-importer.qml#L299
-- 
Your team Music App Developers is requested to review the proposed merge of lp:~ahayzen/music-app/fix-1357324-content-hub-source into lp:music-app.
=== modified file 'app/components/Helpers/ContentHubHelper.qml'
--- app/components/Helpers/ContentHubHelper.qml	2015-07-25 01:22:17 +0000
+++ app/components/Helpers/ContentHubHelper.qml	2015-08-18 21:17:47 +0000
@@ -25,16 +25,24 @@
 
 
 Item {
-    property var activeTransfer
+    property var activeImportTransfer
+    property var activeExportTransfer
+
     property int importId: 0
     property list<ContentItem> importItems
+    property list<ContentItem> exportItems
     property bool processing: contentHubWaitForFile.processId !== -1
 
     ContentTransferHint {
         anchors {
             fill: parent
         }
-        activeTransfer: parent.activeTransfer
+        activeTransfer: parent.activeImportTransfer
+    }
+
+    Component {
+        id: resultComponent
+        ContentItem {}
     }
 
     Connections {
@@ -43,11 +51,17 @@
 
         property var searchPaths: []
 
+        onExportRequested: {
+            activeExportTransfer = transfer;
+
+            mainPageStack.push(Qt.resolvedUrl("../../ui/ContentHubExport.qml"), {contentItemComponent: resultComponent, transfer: activeExportTransfer});
+        }
+
         onImportRequested: {
-            activeTransfer = transfer;
+            activeImportTransfer = transfer;
 
-            if (activeTransfer.state === ContentTransfer.Charged) {
-                importItems = activeTransfer.items;
+            if (activeImportTransfer.state === ContentTransfer.Charged) {
+                importItems = activeImportTransfer.items;
 
                 if (firstRun) {
                     console.debug("Delaying content-hub import")
@@ -155,7 +169,7 @@
             }
 
             // tell content-hub we are finished with the files
-            activeTransfer.finalize();
+            activeImportTransfer.finalize();
         }
     }
 

=== modified file 'app/music-app.qml'
--- app/music-app.qml	2015-07-29 01:23:11 +0000
+++ app/music-app.qml	2015-08-18 21:17:47 +0000
@@ -281,7 +281,7 @@
     property alias queueIndex: startupSettings.queueIndex
     property bool noMusic: allSongsModel.rowCount === 0 && allSongsModelModel.status === SongsModel.Ready && loadedUI
     property bool emptyState: noMusic && !firstRun && !contentHub.processing
-    property Page emptyPage: undefined
+    property Page emptyPage
 
     signal listItemSwiping(int i)
 

=== added file 'app/ui/ContentHubExport.qml'
--- app/ui/ContentHubExport.qml	1970-01-01 00:00:00 +0000
+++ app/ui/ContentHubExport.qml	2015-08-18 21:17:47 +0000
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2015
+ *      Andrew Hayzen <ahayzen@xxxxxxxxx>
+ *      Victor Thompson <victor.thompson@xxxxxxxxx>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import QtQuick 2.4
+import Ubuntu.Components 1.2
+import Ubuntu.Content 1.1
+import Ubuntu.MediaScanner 0.1
+import Ubuntu.Thumbnailer 0.1
+
+import "../components"
+import "../components/Delegates"
+import "../components/Flickables"
+
+
+MusicPage {
+    id: contentHubExportPage
+    title: i18n.tr("Export Song")
+
+    state: "default"
+    states: [
+        PageHeadState {
+            id: defaultState
+            name: "default"
+            actions: [
+                Action {
+                    iconName: "tick"
+                    onTriggered: {
+                        var items = [];
+
+                        for (var i=0; i < trackList.selectedItems.length; i++) {
+                            items.push(contentItemComponent.createObject(contentHubExportPage, {url: songsModelFilter.get(trackList.selectedItems[i]).filename}));
+                        }
+
+                        transfer.items = items;
+                        transfer.state = ContentTransfer.Charged;
+
+                        mainPageStack.pop()
+                    }
+                }
+
+            ]
+            backAction: Action {
+                iconName: "close"
+                onTriggered: {
+                    transfer.items = [];
+                    transfer.state = ContentTransfer.Aborted;
+
+                    mainPageStack.pop()
+                }
+            }
+
+            PropertyChanges {
+                target: contentHubExportPage.head
+                backAction: defaultState.backAction
+                actions: defaultState.actions
+            }
+        }
+    ]
+
+    property var contentItemComponent
+    property var transfer
+    readonly property bool singular: transfer ? transfer.selectionType === ContentTransfer.Single : false
+
+    MultiSelectListView {
+        id: trackList
+        anchors {
+            bottomMargin: units.gu(2)
+            fill: parent
+            topMargin: units.gu(2)
+        }
+        model: SortFilterModel {
+            id: songsModelFilter
+            property alias rowCount: songsModel.rowCount
+            model: SongsModel {
+                id: songsModel
+                store: musicStore
+            }
+            sort.property: "title"
+            sort.order: Qt.AscendingOrder
+            sortCaseSensitivity: Qt.CaseInsensitive
+        }
+
+        property int singularCache: -1
+
+        delegate: MusicListItem {
+            id: track
+            objectName: "tracksPageListItem" + index
+            column: Column {
+                Label {
+                    id: trackTitle
+                    color: styleMusic.common.music
+                    fontSize: "small"
+                    objectName: "tracktitle"
+                    text: model.title
+                }
+
+                Label {
+                    id: trackArtist
+                    color: styleMusic.common.subtitle
+                    fontSize: "x-small"
+                    text: model.author
+                }
+            }
+            height: units.gu(7)
+            imageSource: {"art": model.art}
+            multiselectable: true
+            selectionMode: true
+
+            onSelectedChanged: {
+                // in singular mode only allow one item to be selected
+                if (singular && selected && trackList.singularCache === -1) {
+                    trackList.singularCache = index;
+
+                    trackList.clearSelection();
+                    selected = true;
+
+                    trackList.singularCache = -1;
+                }
+            }
+        }
+
+        Component.onCompleted: state = "multiselectable"
+    }
+}

=== modified file 'apparmor.json'
--- apparmor.json	2015-05-02 20:21:56 +0000
+++ apparmor.json	2015-08-18 21:17:47 +0000
@@ -3,6 +3,7 @@
     "policy_groups": [
         "audio",
         "content_exchange",
+        "content_exchange_source",
         "music_files_read",
         "networking",
         "usermetrics"
@@ -15,4 +16,4 @@
     "write_path": [
         "@{HOME}/Music/Imported/"
     ]
-}
\ No newline at end of file
+}

=== modified file 'debian/changelog'
--- debian/changelog	2015-08-08 18:32:22 +0000
+++ debian/changelog	2015-08-18 21:17:47 +0000
@@ -8,6 +8,7 @@
 
   [ Andrew Hayzen ]
   * Fix for console errors when using the parent changed helpers
+  * Add support for a content-hub source in both single and multiple selection modes (LP: #1357324)
 
  -- Victor Thompson <victor.thompson@xxxxxxxxx>  Thu, 23 Jul 2015 21:08:38 -0500
 

=== modified file 'music-app-content.json'
--- music-app-content.json	2015-01-28 17:45:43 +0000
+++ music-app-content.json	2015-08-18 21:17:47 +0000
@@ -1,5 +1,8 @@
 {
     "destination": [
         "music"
+    ],
+    "source": [
+        "music"
     ]
 }