Merge lp:~etherpulse/podbird/download_wifi into lp:podbird/devel

Proposed by Eran Uzan
Status: Merged
Approved by: Nekhelesh Ramananthan
Approved revision: 156
Merged at revision: 155
Proposed branch: lp:~etherpulse/podbird/download_wifi
Merge into: lp:podbird/devel
Diff against target: 212 lines (+47/-21)
6 files modified
app/podbird.qml (+3/-2)
app/podcasts.js (+1/-1)
app/ui/EpisodesPage.qml (+2/-2)
app/ui/EpisodesTab.qml (+2/-2)
app/ui/SettingsPage.qml (+17/-0)
po/podbird.nik90.pot (+22/-14)
To merge this branch: bzr merge lp:~etherpulse/podbird/download_wifi
Reviewer Review Type Date Requested Status
Nekhelesh Ramananthan Approve
Review via email: mp+309158@code.launchpad.net

Description of the change

Fix for the 'Provide setting option to disable downloads over cellular data' issue (lp:1456300).

Implemented by simply adding a switch to the settings and used the switch state to set the SingleDownload.allowMobileDownload flag provided by ubuntu API (Ubuntu.DownloadManager 1.2).

It will now allow manual download to work on mobile even though auto downloads are held back.

Also changed to devel branch.

To post a comment you must log in.
Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

Thanks a lot for the above patch. May I ask on which device you tested this? The last time I implemented this patch, we noticed that during testing it did not work on BQ devices. And since then we haven't tested it to check if this was fixed.

review: Needs Information
Revision history for this message
Eran Uzan (etherpulse) wrote :

Hey Nekhelesh, I have a Meizu 5 PRO
I guess it will have to be tested on a BQ device to know if the support was added... not sure if it was as I couldn't find any bug in the ubuntu-download-manager that refer to it directly (there's was lp:1451090 but i`m not sure it`s related )

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

Sorry for the late reply. My development laptop just died of old age. I am almost done getting a new development environment set up on another laptop. Looking through the code, I see a few areas which could be improved.

I think that the !mobileDl assigned to allowMobileDownload is a bit confusing to be honest. I would rather it be just mobileDl. This would make the following lines much more intuitive since Podbird should allow the user to download over mobile connection if they so wish to do so. But since you have assigned it as !mobileDl, we are forced to pass it as false in other parts of the code.

- podbird.downloadEpisode(episodeModel.get(index).image, episodeModel.get(index).name, episodeModel.get(index).guid, episodeModel.get(index).audiourl)
+ podbird.downloadEpisode(episodeModel.get(index).image, episodeModel.get(index).name, episodeModel.get(index).guid, episodeModel.get(index).audiourl, false)

- podbird.downloadEpisode(model.image, model.name, model.guid, model.audiourl)
+ podbird.downloadEpisode(model.image, model.name, model.guid, model.audiourl, false)

review: Needs Fixing
Revision history for this message
Eran Uzan (etherpulse) wrote :

Hey , Sorry to hear about your loss I hope the laptop had a fulfilling life of development and and creation ;)
I hope it won't be too much of an hassle....

About the negative logic it bothered me too but I kept it this way to support legacy code and to prevent unintended behaviour by other developers, As calling the function without the mobileDl argument will do the same thing as before I added the argument (as "!undefined" will be evaluated to "true").

I would suggest changing the name of the argument to disableMobileDl which then will make sense with the logic it self.

But I can change it if you want...

Hope your new laptop will serve you well,

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

> Hey , Sorry to hear about your loss I hope the laptop had a fulfilling life of
> development and and creation ;)
> I hope it won't be too much of an hassle....
>
> About the negative logic it bothered me too but I kept it this way to support
> legacy code and to prevent unintended behaviour by other developers, As
> calling the function without the mobileDl argument will do the same thing as
> before I added the argument (as "!undefined" will be evaluated to "true").
>
> I would suggest changing the name of the argument to disableMobileDl which
> then will make sense with the logic it self.

I think this is a good idea. Can you rename the variable to disableMobileDownload? This way as you say your logic remains the same while making it more clear.

>
> But I can change it if you want...
>
>
> Hope your new laptop will serve you well,

Thanks :). I've got 16.04 up and running with the new SDK. Will test the code on the phone when I get home tonight.

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

Hey Eran, I tested your branch on my BQ E4.5 and it works nicely. Podcasts are automatically downloaded only when on wifi. Nice work!

So here are the few final things before I merge your code,
1. Set the default value to True. By default, we will automatically download podcasts over wifi only. I think this will avoid any unpleasant surprises to new user.

2. Rename the variable to disableMobileDownload as mentioned before to make the code more clear.

review: Needs Fixing
lp:~etherpulse/podbird/download_wifi updated
156. By Eran Uzan

Change the wifi download limit default to true and chnage th e code to be a little clearer

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

LGTM! Nice work! Thanks a lot for the patch!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/podbird.qml'
2--- app/podbird.qml 2016-10-07 00:25:11 +0000
3+++ app/podbird.qml 2016-11-16 21:49:49 +0000
4@@ -117,6 +117,7 @@
5 property bool showListView: true
6 property int skipForward: 30
7 property int skipBack: 10
8+ property bool downloadOverWifiOnly: true
9 }
10
11 FileManager {
12@@ -171,8 +172,8 @@
13 }
14 }
15
16- function downloadEpisode(image, title, guid, url) {
17- var singleDownload = singleDownloadComponent.createObject(podbird, {"image": image, "title": title, "guid": guid})
18+ function downloadEpisode(image, title, guid, url, disableMobileDownload) {
19+ var singleDownload = singleDownloadComponent.createObject(podbird, {"image": image, "title": title, "guid": guid , allowMobileDownload : !disableMobileDownload })
20 singleDownload.download(url)
21 }
22
23
24=== modified file 'app/podcasts.js'
25--- app/podcasts.js 2016-03-29 11:02:18 +0000
26+++ app/podcasts.js 2016-11-16 21:49:49 +0000
27@@ -360,7 +360,7 @@
28 var loopCount = maxEpisodeDownload > rs2.rows.length ? rs2.rows.length : maxEpisodeDownload
29 for (var j=0; j < loopCount; j++) {
30 if (!rs2.rows.item(j).downloadedfile && !rs2.rows.item(j).listened && rs2.rows.item(j).audiourl) {
31- podbird.downloadEpisode(rs.rows.item(i).image, rs2.rows.item(j).name, rs2.rows.item(j).guid, rs2.rows.item(j).audiourl)
32+ podbird.downloadEpisode(rs.rows.item(i).image, rs2.rows.item(j).name, rs2.rows.item(j).guid, rs2.rows.item(j).audiourl, podbird.settings.downloadOverWifiOnly)
33 tx.executeSql("UPDATE Episode SET queued=1 WHERE guid = ?", [rs2.rows.item(j).guid]);
34 }
35 }
36
37=== modified file 'app/ui/EpisodesPage.qml'
38--- app/ui/EpisodesPage.qml 2016-09-22 21:47:24 +0000
39+++ app/ui/EpisodesPage.qml 2016-11-16 21:49:49 +0000
40@@ -166,7 +166,7 @@
41 episodeModel.setProperty(index, "queued", 1)
42 tx.executeSql("UPDATE Episode SET queued=1 WHERE guid = ?", [episodeModel.get(index).guid]);
43 if (episodeModel.get(index).audiourl) {
44- podbird.downloadEpisode(episodeModel.get(index).image, episodeModel.get(index).name, episodeModel.get(index).guid, episodeModel.get(index).audiourl)
45+ podbird.downloadEpisode(episodeModel.get(index).image, episodeModel.get(index).name, episodeModel.get(index).guid, episodeModel.get(index).audiourl, false)
46 } else {
47 console.log("[ERROR]: Invalid download url: " + episodeModel.get(index).audiourl)
48 }
49@@ -633,7 +633,7 @@
50 });
51 episodeModel.setProperty(model.index, "queued", 1)
52 if (model.audiourl) {
53- podbird.downloadEpisode(model.image, model.name, model.guid, model.audiourl)
54+ podbird.downloadEpisode(model.image, model.name, model.guid, model.audiourl, false)
55 } else {
56 console.log("[ERROR]: Invalid download url: " + model.audiourl)
57 }
58
59=== modified file 'app/ui/EpisodesTab.qml'
60--- app/ui/EpisodesTab.qml 2016-10-07 00:25:11 +0000
61+++ app/ui/EpisodesTab.qml 2016-11-16 21:49:49 +0000
62@@ -183,7 +183,7 @@
63 episodesModel.setProperty(index, "queued", 1)
64 tx.executeSql("UPDATE Episode SET queued=1 WHERE guid = ?", [episodesModel.get(index).guid]);
65 if (episodesModel.get(index).audiourl) {
66- podbird.downloadEpisode(episodesModel.get(index).image, episodesModel.get(index).name, episodesModel.get(index).guid, episodesModel.get(index).audiourl)
67+ podbird.downloadEpisode(episodesModel.get(index).image, episodesModel.get(index).name, episodesModel.get(index).guid, episodesModel.get(index).audiourl, false)
68 } else {
69 console.log("[ERROR]: Invalid download url: " + episodesModel.get(index).audiourl)
70 }
71@@ -597,7 +597,7 @@
72 });
73 episodesModel.setProperty(model.index, "queued", 1)
74 if (model.audiourl) {
75- podbird.downloadEpisode(model.image, model.name, model.guid, model.audiourl)
76+ podbird.downloadEpisode(model.image, model.name, model.guid, model.audiourl, false)
77 } else {
78 console.log("[ERROR]: Invalid download url: " + model.audiourl)
79 }
80
81=== modified file 'app/ui/SettingsPage.qml'
82--- app/ui/SettingsPage.qml 2016-05-30 17:51:38 +0000
83+++ app/ui/SettingsPage.qml 2016-11-16 21:49:49 +0000
84@@ -212,6 +212,23 @@
85 onClicked: mainStack.push(Qt.resolvedUrl("../settings/DownloadSetting.qml"))
86 }
87
88+ ListItem {
89+ ListItemLayout {
90+ id: downloadWifiOnlyLayout
91+ title.text: i18n.tr("Only download over wifi")
92+ title.color: podbird.appTheme.baseText
93+ summary.text: i18n.tr("Download episodes only when the device is using WiFi")
94+ summary.color: podbird.appTheme.baseSubText
95+ Switch {
96+ SlotsLayout.position: SlotsLayout.Last
97+ checked: podbird.settings.downloadOverWifiOnly
98+ onClicked: podbird.settings.downloadOverWifiOnly = checked
99+ }
100+ }
101+ divider.visible: false
102+ height: downloadWifiOnlyLayout.height
103+ }
104+
105 ListItem {
106 id: refreshArtListItem
107
108
109=== modified file 'po/podbird.nik90.pot'
110--- po/podbird.nik90.pot 2016-10-07 00:25:11 +0000
111+++ po/podbird.nik90.pot 2016-11-16 21:49:49 +0000
112@@ -8,7 +8,7 @@
113 msgstr ""
114 "Project-Id-Version: \n"
115 "Report-Msgid-Bugs-To: \n"
116-"POT-Creation-Date: 2016-10-06 23:37+0000\n"
117+"POT-Creation-Date: 2016-10-24 19:03+0000\n"
118 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
119 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
120 "Language-Team: LANGUAGE <LL@li.org>\n"
121@@ -55,7 +55,7 @@
122
123 #. TRANSLATORS: About as in information about the app
124 #: ../app/settings/About.qml:28 ../app/settings/About.qml:46
125-#: ../app/ui/SettingsPage.qml:321
126+#: ../app/ui/SettingsPage.qml:338
127 msgid "About"
128 msgstr ""
129
130@@ -223,7 +223,7 @@
131 msgstr ""
132
133 #: ../app/ui/EpisodesPage.qml:356 ../app/ui/EpisodesTab.qml:418
134-#: ../app/ui/SearchPage.qml:179 ../app/ui/SettingsPage.qml:303
135+#: ../app/ui/SearchPage.qml:179 ../app/ui/SettingsPage.qml:320
136 msgid "Close"
137 msgstr ""
138
139@@ -518,43 +518,51 @@
140 msgid "Default number of new episodes to download for each podcast"
141 msgstr ""
142
143-#: ../app/ui/SettingsPage.qml:223
144+#: ../app/ui/SettingsPage.qml:218
145+msgid "Only download over wifi"
146+msgstr ""
147+
148+#: ../app/ui/SettingsPage.qml:220
149+msgid "Download episodes only when the device is using WiFi"
150+msgstr ""
151+
152+#: ../app/ui/SettingsPage.qml:240
153 msgid "Refresh podcast artwork"
154 msgstr ""
155
156-#: ../app/ui/SettingsPage.qml:225
157+#: ../app/ui/SettingsPage.qml:242
158 msgid ""
159 "Update all podcasts artwork and fix missing ones (this only works with "
160 "podcasts added via iTunesĀ® search)"
161 msgstr ""
162
163-#: ../app/ui/SettingsPage.qml:254
164+#: ../app/ui/SettingsPage.qml:271
165 msgid "Storage Settings"
166 msgstr ""
167
168-#: ../app/ui/SettingsPage.qml:265
169+#: ../app/ui/SettingsPage.qml:282
170 msgid "Delete orphaned files and links"
171 msgstr ""
172
173-#: ../app/ui/SettingsPage.qml:267
174+#: ../app/ui/SettingsPage.qml:284
175 msgid "Free space by removing orphaned downloaded files and links"
176 msgstr ""
177
178-#: ../app/ui/SettingsPage.qml:297
179+#: ../app/ui/SettingsPage.qml:314
180 msgid "Removed Orphaned files and links"
181 msgstr ""
182
183-#: ../app/ui/SettingsPage.qml:297
184+#: ../app/ui/SettingsPage.qml:314
185 msgid "No Orphans found!"
186 msgstr ""
187
188-#: ../app/ui/SettingsPage.qml:298
189+#: ../app/ui/SettingsPage.qml:315
190 msgid ""
191 "All orphaned files have been deleted to recover disk space. Orphaned links "
192 "pointing at invalid files have also been cleaned up."
193 msgstr ""
194
195-#: ../app/ui/SettingsPage.qml:300
196+#: ../app/ui/SettingsPage.qml:317
197 msgid ""
198 "No orphaned files have been found to recover disk space. Podbird database is "
199 "clean."
200@@ -562,11 +570,11 @@
201
202 #. TRANSLATORS: Shortened form of "Miscellaneous" which is shown to denote other setting options
203 #. that doesn't fit into any other category.
204-#: ../app/ui/SettingsPage.qml:315
205+#: ../app/ui/SettingsPage.qml:332
206 msgid "Misc."
207 msgstr ""
208
209-#: ../app/ui/SettingsPage.qml:331
210+#: ../app/ui/SettingsPage.qml:348
211 msgid "Report Bug"
212 msgstr ""
213

Subscribers

People subscribed via source and target branches

to all changes: