Merge lp:~ken-vandine/ubuntu-system-settings/custom_ringtone into lp:ubuntu-system-settings

Proposed by Ken VanDine
Status: Merged
Approved by: Jonas G. Drange
Approved revision: 1562
Merged at revision: 1564
Proposed branch: lp:~ken-vandine/ubuntu-system-settings/custom_ringtone
Merge into: lp:ubuntu-system-settings
Diff against target: 355 lines (+202/-50)
4 files modified
plugins/background/MainPage.qml (+1/-1)
plugins/sound/SoundsList.qml (+176/-49)
plugins/sound/sound.cpp (+19/-0)
plugins/sound/sound.h (+6/-0)
To merge this branch: bzr merge lp:~ken-vandine/ubuntu-system-settings/custom_ringtone
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Jonas G. Drange (community) Approve
Review via email: mp+277576@code.launchpad.net

Commit message

Allow setting custom ringtone with content-hub

Description of the change

Allow setting custom ringtone with content-hub

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

delete custom ringtone when it's no longer used

1558. By Ken VanDine

don't remove custom ringtone if it's still being used for other messages

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1559. By Ken VanDine

Updated visuals of the stop playback control to match design

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1560. By Ken VanDine

Don't specifically set the height on the ItemSelector

Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

Two issues:

* There's a bug in the flickable. I'm unable to scroll to the end. Let me create some steps to repro
* double header http://i.imgur.com/gSM3vyl.png

Otherwise it works well and looks good!

review: Needs Fixing
Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

Steps to repro:
1. USS -> Sound -> Ringtone
2. Quickly swipe down in the list

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1561. By Ken VanDine

Fixes in the SoundsList flickable

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1562. By Ken VanDine

Don't show the page title in the peer picker and use progression to indicate the peer picker is a page

Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

Looks good and works well. Thanks!

review: Approve
1563. By Ken VanDine

Only show the custom ringtone picker for incoming calls

1564. By Ken VanDine

merged trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1565. By Ken VanDine

Don't include the custom ringtone for messages

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/background/MainPage.qml'
--- plugins/background/MainPage.qml 2015-08-10 13:31:45 +0000
+++ plugins/background/MainPage.qml 2015-11-20 13:12:56 +0000
@@ -21,7 +21,7 @@
21import QtQuick 2.421import QtQuick 2.4
22import GSettings 1.022import GSettings 1.0
23import SystemSettings 1.023import SystemSettings 1.0
24import Ubuntu.Content 0.124import Ubuntu.Content 1.3
25import Ubuntu.Components 1.325import Ubuntu.Components 1.3
26import Ubuntu.Components.ListItems 1.3 as ListItem26import Ubuntu.Components.ListItems 1.3 as ListItem
27import Ubuntu.Components.Popups 1.327import Ubuntu.Components.Popups 1.3
2828
=== modified file 'plugins/sound/SoundsList.qml'
--- plugins/sound/SoundsList.qml 2015-10-16 13:42:50 +0000
+++ plugins/sound/SoundsList.qml 2015-11-20 13:12:56 +0000
@@ -2,6 +2,7 @@
2import QtQuick 2.42import QtQuick 2.4
3import QtMultimedia 5.03import QtMultimedia 5.0
4import SystemSettings 1.04import SystemSettings 1.0
5import Ubuntu.Content 1.3
5import Ubuntu.Components 1.36import Ubuntu.Components 1.3
6import Ubuntu.Components.ListItems 1.3 as ListItem7import Ubuntu.Components.ListItems 1.3 as ListItem
7import Ubuntu.SystemSettings.Sound 1.08import Ubuntu.SystemSettings.Sound 1.0
@@ -12,13 +13,25 @@
12ItemPage {13ItemPage {
13 property variant soundDisplayNames:14 property variant soundDisplayNames:
14 Utilities.buildSoundValues(soundFileNames)15 Utilities.buildSoundValues(soundFileNames)
15 property variant soundFileNames: backendInfo.listSounds(16 property variant soundFileNames: refreshSoundFileNames()
16 [soundsDir, "/custom" + soundsDir])
17 property bool showStopButton: false17 property bool showStopButton: false
18 property int soundType // 0: ringtone, 1: message18 property int soundType // 0: ringtone, 1: message
19 property string soundsDir19 property string soundsDir
20 property var activeTransfer
21
22 onSoundFileNamesChanged: {
23 soundDisplayNames = Utilities.buildSoundValues(soundFileNames)
24 updateSelectedIndex()
25 }
2026
21 id: soundsPage27 id: soundsPage
28 flickable: scrollWidget
29
30 function refreshSoundFileNames() {
31 if (soundType === 0)
32 return backendInfo.listSounds([soundsDir, "/custom" + soundsDir, backendInfo.customRingtonePath])
33 return backendInfo.listSounds([soundsDir, "/custom" + soundsDir])
34 }
2235
23 UbuntuSoundPanel {36 UbuntuSoundPanel {
24 id: backendInfo37 id: backendInfo
@@ -55,52 +68,166 @@
55 audioRole: MediaPlayer.alert68 audioRole: MediaPlayer.alert
56 }69 }
5770
58 Column {71 function setRingtone(path) {
59 id: columnId72 if (soundType == 0) {
60 anchors.left: parent.left73 soundSettings.incomingCallSound = path
61 anchors.right: parent.right74 backendInfo.incomingCallSound = path
6275 } else if (soundType == 1) {
63 ListItem.SingleControl {76 soundSettings.incomingMessageSound = path
64 id: listId77 backendInfo.incomingMessageSound = path
65 control: Button {78 }
66 text: i18n.tr("Stop playing")79 soundFileNames = refreshSoundFileNames()
67 width: parent.width - units.gu(4)80 soundEffect.source = path
68 onClicked:81 soundEffect.play()
69 soundEffect.stop()82 }
70 }83
84 function updateSelectedIndex() {
85 if (soundType == 0)
86 soundSelector.selectedIndex =
87 Utilities.indexSelectedFile(soundFileNames,
88 backendInfo.incomingCallSound)
89 else if (soundType == 1)
90 soundSelector.selectedIndex =
91 Utilities.indexSelectedFile(soundFileNames,
92 backendInfo.incomingMessageSound)
93 }
94
95 Flickable {
96 id: scrollWidget
97 anchors.fill: parent
98 contentWidth: parent.width
99 contentHeight: selectorColumn.height + stopItem.height
100 boundsBehavior: (contentHeight > height) ?
101 Flickable.DragAndOvershootBounds :
102 Flickable.StopAtBounds
103 /* Set the direction to workaround https://bugreports.qt-project.org/browse/QTBUG-31905
104 otherwise the UI might end up in a situation where scrolling doesn't work */
105 flickableDirection: Flickable.VerticalFlick
106
107 Column {
108 id: selectorColumn
109 anchors.left: parent.left
110 anchors.right: parent.right
111
112 ListItem.ItemSelector {
113 id: soundSelector
114 expanded: true
115 model: soundDisplayNames
116 selectedIndex: {
117 updateSelectedIndex()
118 }
119 onDelegateClicked: {
120 setRingtone(soundFileNames[index])
121 }
122 }
123
124 ListItem.Standard {
125 id: customRingtone
126 text: i18n.tr("Custom Ringtone")
127 visible: soundType === 0
128 progression: true
129 onClicked: {
130 pageStack.push(picker);
131 }
132 }
133 }
134 }
135
136 ListItem.SingleControl {
137 id: stopItem
138 anchors.bottom: parent.bottom
139 control: AbstractButton {
140 id: stopButton
141 anchors.verticalCenter: parent.verticalCenter
142 anchors.horizontalCenter: parent.horizontalCenter
143 focus: false
144 width: height
145 height: units.gu(4)
71 enabled: soundEffect.playbackState == Audio.PlayingState146 enabled: soundEffect.playbackState == Audio.PlayingState
72 visible: showStopButton147 visible: enabled
73 }148
74 }149 onClicked: soundEffect.stop()
75150
76 ListItem.ItemSelector {151 Rectangle {
77 id: soundSelector152 anchors.fill: parent
78 anchors.top: columnId.bottom153 radius: width * 0.5
79 anchors.bottom: soundsPage.bottom154 border.color: UbuntuColors.warmGrey
80 containerHeight: height155 border.width: 1
81156 }
82 expanded: true157
83 model: soundDisplayNames158 Rectangle {
84 selectedIndex: {159 width: parent.height * 0.4
85 if (soundType == 0)160 height: width
86 soundSelector.selectedIndex =161 smooth: true
87 Utilities.indexSelectedFile(soundFileNames,162 anchors {
88 backendInfo.incomingCallSound)163 verticalCenter: parent.verticalCenter
89 else if (soundType == 1)164 horizontalCenter: parent.horizontalCenter
90 soundSelector.selectedIndex =165 }
91 Utilities.indexSelectedFile(soundFileNames,166 color: UbuntuColors.warmGrey
92 backendInfo.incomingMessageSound)167 }
93 }168 }
94 onDelegateClicked: {169 Rectangle {
95 if (soundType == 0) {170 anchors.fill: parent
96 soundSettings.incomingCallSound = soundFileNames[index]171 z: parent.z - 1
97 backendInfo.incomingCallSound = soundFileNames[index]172 visible: stopButton.visible
98 } else if (soundType == 1) {173 color: Theme.palette.normal.background
99 soundSettings.incomingMessageSound = soundFileNames[index]174 }
100 backendInfo.incomingMessageSound = soundFileNames[index]175 }
101 }176
102 soundEffect.source = soundFileNames[index]177 Connections {
103 soundEffect.play()178 id: contentHubConnection
104 }179 property var ringtoneCallback
105 }180 target: activeTransfer ? activeTransfer : null
181 onStateChanged: {
182 if (activeTransfer.state === ContentTransfer.Charged) {
183 if (activeTransfer.items.length > 0) {
184 var toneUri = activeTransfer.items[0].url;
185 ringtoneCallback(toneUri);
186 }
187 }
188 }
189 }
190
191 Page {
192 id: picker
193 visible: false
194
195 ContentStore {
196 id: appStore
197 scope: ContentScope.App
198 }
199
200 ContentPeerPicker {
201 id: peerPicker
202 visible: parent.visible
203 handler: ContentHandler.Source
204 contentType: ContentType.Music
205 showTitle: false
206
207 onPeerSelected: {
208 pageStack.pop();
209 // requests an active transfer from peer
210 function startContentTransfer(callback) {
211 if (callback)
212 contentHubConnection.ringtoneCallback = callback
213 var transfer = peer.request(appStore);
214 if (transfer !== null) {
215 soundsPage.activeTransfer = transfer;
216 }
217 }
218 peer.selectionType = ContentTransfer.Single;
219 startContentTransfer(function(uri) {
220 setRingtone(uri.toString().replace("file:///", "/"));
221 });
222 }
223
224 onCancelPressed: pageStack.pop();
225 }
226 }
227
228 ContentTransferHint {
229 anchors.fill: parent
230 activeTransfer: soundsPage.activeTransfer
231 }
232
106}233}
107234
=== modified file 'plugins/sound/sound.cpp'
--- plugins/sound/sound.cpp 2015-01-28 11:37:35 +0000
+++ plugins/sound/sound.cpp 2015-11-20 13:12:56 +0000
@@ -21,6 +21,8 @@
21#include "sound.h"21#include "sound.h"
2222
23#include <QDir>23#include <QDir>
24#include <QFile>
25#include <QStandardPaths>
24#include <unistd.h>26#include <unistd.h>
2527
26#define AS_INTERFACE "com.ubuntu.touch.AccountsService.Sound"28#define AS_INTERFACE "com.ubuntu.touch.AccountsService.Sound"
@@ -88,10 +90,16 @@
88 if (sound == getIncomingCallSound())90 if (sound == getIncomingCallSound())
89 return;91 return;
9092
93 QString prevSound = getIncomingCallSound();
94
91 m_accountsService.setUserProperty(AS_INTERFACE,95 m_accountsService.setUserProperty(AS_INTERFACE,
92 "IncomingCallSound",96 "IncomingCallSound",
93 QVariant::fromValue(sound));97 QVariant::fromValue(sound));
94 Q_EMIT(incomingCallSoundChanged());98 Q_EMIT(incomingCallSoundChanged());
99
100 if (prevSound.startsWith(QString(QStandardPaths::writableLocation(QStandardPaths::DataLocation))) &&
101 prevSound != getIncomingMessageSound())
102 QFile(prevSound).remove();
95}103}
96104
97QString Sound::getIncomingMessageSound()105QString Sound::getIncomingMessageSound()
@@ -105,10 +113,16 @@
105 if (sound == getIncomingMessageSound())113 if (sound == getIncomingMessageSound())
106 return;114 return;
107115
116 QString prevSound = getIncomingMessageSound();
117
108 m_accountsService.setUserProperty(AS_INTERFACE,118 m_accountsService.setUserProperty(AS_INTERFACE,
109 "IncomingMessageSound",119 "IncomingMessageSound",
110 QVariant::fromValue(sound));120 QVariant::fromValue(sound));
121
111 Q_EMIT(incomingMessageSoundChanged());122 Q_EMIT(incomingMessageSoundChanged());
123 if (prevSound.startsWith(QString(QStandardPaths::writableLocation(QStandardPaths::DataLocation))) &&
124 prevSound != getIncomingCallSound())
125 QFile(prevSound).remove();
112}126}
113127
114bool Sound::getIncomingCallVibrate()128bool Sound::getIncomingCallVibrate()
@@ -213,6 +227,11 @@
213 Q_EMIT(dialpadSoundsEnabledChanged());227 Q_EMIT(dialpadSoundsEnabledChanged());
214}228}
215229
230QString Sound::customRingtonePath()
231{
232 return QString(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/Music");
233}
234
216QStringList soundsListFromDir(const QString &dirString)235QStringList soundsListFromDir(const QString &dirString)
217{236{
218 QDir soundsDir(dirString);237 QDir soundsDir(dirString);
219238
=== modified file 'plugins/sound/sound.h'
--- plugins/sound/sound.h 2015-01-28 11:37:35 +0000
+++ plugins/sound/sound.h 2015-11-20 13:12:56 +0000
@@ -67,6 +67,10 @@
67 WRITE setDialpadSoundsEnabled67 WRITE setDialpadSoundsEnabled
68 NOTIFY dialpadSoundsEnabledChanged)68 NOTIFY dialpadSoundsEnabledChanged)
6969
70 Q_PROPERTY (QString customRingtonePath
71 READ customRingtonePath
72 NOTIFY customRingtonePathChanged)
73
7074
71public Q_SLOTS:75public Q_SLOTS:
72 void slotChanged(QString, QString);76 void slotChanged(QString, QString);
@@ -81,6 +85,7 @@
81 void incomingMessageVibrateSilentModeChanged();85 void incomingMessageVibrateSilentModeChanged();
82 void otherVibrateChanged();86 void otherVibrateChanged();
83 void dialpadSoundsEnabledChanged();87 void dialpadSoundsEnabledChanged();
88 void customRingtonePathChanged();
8489
85private:90private:
86 AccountsService m_accountsService;91 AccountsService m_accountsService;
@@ -101,6 +106,7 @@
101 void setOtherVibrate(bool enabled);106 void setOtherVibrate(bool enabled);
102 bool getDialpadSoundsEnabled();107 bool getDialpadSoundsEnabled();
103 void setDialpadSoundsEnabled(bool enabled);108 void setDialpadSoundsEnabled(bool enabled);
109 QString customRingtonePath();
104110
105};111};
106112

Subscribers

People subscribed via source and target branches