diff --git a/qml/EpisodeItem.qml b/qml/EpisodeItem.qml
index 71f8bed..97bb2e1 100644
--- a/qml/EpisodeItem.qml
+++ b/qml/EpisodeItem.qml
@@ -23,11 +23,13 @@ import Sailfish.Silica 1.0
import 'common/constants.js' as Constants
import 'common/util.js' as Util
+import 'connectionManagement'
ListItem {
id: episodeItem
property bool isPlaying: ((player.episode === id) && player.isPlaying)
property variant mime: mime_type.split('/')
+ property var downloaded: downloadState === 1
Rectangle {
anchors.fill: parent
@@ -73,9 +75,27 @@ ListItem {
if (episodeItem.isPlaying) {
player.pause();
} else {
- player.playbackEpisode(id);
+ if(downloaded === false){
+ // curried function below to create a closure
+ // see e.g. https://stackoverflow.com/questions/28898526
+ connectionUtil.executeIfConnectionAllowed(
+ function(callee, argument1, argument2){
+ return function(){
+ callee(argument1,argument2)};
+ }(doPlayback,player,id)
+ );
+ }else {
+ doPlayback(player,id);
+ }
}
}
+
+ function doPlayback(mediaPlayer,id){
+ console.info("playing episode", id);
+ mediaPlayer.playbackEpisode(id);
+ }
+
+
}
IconMenuItem {
diff --git a/qml/Main.qml b/qml/Main.qml
index 4eb9602..272638d 100644
--- a/qml/Main.qml
+++ b/qml/Main.qml
@@ -20,8 +20,10 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
+import Nemo.Configuration 1.0
import 'common'
+import 'connectionManagement'
PodcastsPage {
id: pgst
@@ -72,6 +74,10 @@ PodcastsPage {
MprisPlayer {}
MediaKeys {}
+ ConnectionUtils {
+ id: connectionUtil
+ }
+
GPodderPodcastListModel { id: podcastListModel }
GPodderPodcastListModelConnections {}
@@ -99,4 +105,11 @@ PodcastsPage {
visible: !py.ready
running: visible
}
+
+ ConfigurationValue {
+ id: configCellularDownloadsEnabled
+ key: "/apps/ControlPanel/gpodder/cellularDownloadsEnabled"
+ defaultValue: false
+ }
+
}
diff --git a/qml/SettingsPage.qml b/qml/SettingsPage.qml
index f5407cb..8c01b79 100644
--- a/qml/SettingsPage.qml
+++ b/qml/SettingsPage.qml
@@ -35,10 +35,12 @@ Page {
py.getConfig('limit.episodes', function (value) {
limit_episodes.value = value;
});
+ cellularDownloadsEnabled.checked = configCellularDownloadsEnabled.value;
} else if (status === PageStatus.Deactivating) {
py.setConfig('plugins.youtube.api_key_v3', youtube_api_key_v3.text);
py.setConfig('limit.episodes', parseInt(limit_episodes.value));
youtube_api_key_v3.focus = false;
+ configCellularDownloadsEnabled.value = cellularDownloadsEnabled.checked
}
}
@@ -92,6 +94,13 @@ Page {
maximumValue: 1000
stepSize: 100
}
+
+ TextSwitch {
+ id: cellularDownloadsEnabled
+ text: qsTr("Allow Downloads via mobile data")
+ checked: configCellularDownloadsEnabled.value
+ }
+
}
}
}
diff --git a/qml/connectionManagement/ConnectionBlockedDialog.qml b/qml/connectionManagement/ConnectionBlockedDialog.qml
new file mode 100644
index 0000000..aa7b2c3
--- /dev/null
+++ b/qml/connectionManagement/ConnectionBlockedDialog.qml
@@ -0,0 +1,16 @@
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+
+ Dialog {
+ Column {
+ width: parent.width
+
+ DialogHeader {
+ title: "Connection blocked"
+ }
+ Label{
+ text: "Make an exception for now?"
+ }
+ }
+
+ }
diff --git a/qml/connectionManagement/ConnectionUtils.qml b/qml/connectionManagement/ConnectionUtils.qml
new file mode 100644
index 0000000..f1f8fa4
--- /dev/null
+++ b/qml/connectionManagement/ConnectionUtils.qml
@@ -0,0 +1,54 @@
+import QtQuick 2.0
+import Nemo.DBus 2.0
+
+QtObject {
+
+ property DBusInterface connmanWifi: DBusInterface {
+ bus: DBus.SystemBus
+ service: "net.connman"
+ path: "/net/connman/technology/wifi"
+ iface: "net.connman.Technology"
+
+ property bool wifiConnected
+
+ signalsEnabled: true
+ function propertyChanged(name, value) {
+ if (name === "Connected") {
+ wifiConnected = value
+ }
+ }
+
+ function getProperties() {
+ typedCall('GetProperties', undefined, function(result) {
+ wifiConnected = result['Connected']})
+ }
+ Component.onCompleted: getProperties();
+
+ onWifiConnectedChanged: {
+ console.debug("wifistate is now",wifiConnected)
+ }
+ }
+
+ function checkConnection(ignoreConnection){
+ var cellularAllowed = configCellularDownloadsEnabled.value === true || ignoreConnection === true;
+ console.debug("Connection check: cellular allowed:",cellularAllowed," wifi connected: ", connmanWifi.wifiConnected)
+ return cellularAllowed || connmanWifi.wifiConnected;
+ }
+
+
+ /**
+ * @return signal binding for executing callback anyway
+ **/
+ function downloadBlockedDialog(callback){
+ console.info("creating connection blocked dialog, because not on wifi!");
+ pageStack.push("ConnectionBlockedDialog.qml").accepted.connect(callback)
+ }
+
+ function executeIfConnectionAllowed(callback){
+ if(checkConnection())
+ callback()
+ else
+ downloadBlockedDialog(callback)
+ }
+
+}
diff --git a/translations/harbour-org.gpodder.sailfish-bg.ts b/translations/harbour-org.gpodder.sailfish-bg.ts
index d47bac0..2b1e186 100644
--- a/translations/harbour-org.gpodder.sailfish-bg.ts
+++ b/translations/harbour-org.gpodder.sailfish-bg.ts
@@ -97,44 +97,44 @@
EpisodeItem
-
+
- Паузиране
+ Паузиране
-
+
- Пускане
+ Пускане
-
+
- Изтегляне
+
-
+
- Към опашката
+
-
+
- Изтриване
+
-
+
- Изтрива се
+
-
+
- Като нов
+
-
+
- Описание
+ Описание
@@ -512,35 +512,40 @@
SettingsPage
-
+
Относно
-
+
Настройки
-
+
YouTube
-
+
API ключ (v3)
-
+
Ограничения
-
+
Максимален брой епизоди за RSS емисия
+
+
+
+
+
SleepTimerDialog
diff --git a/translations/harbour-org.gpodder.sailfish-de.ts b/translations/harbour-org.gpodder.sailfish-de.ts
index 75df417..e7dbcc3 100644
--- a/translations/harbour-org.gpodder.sailfish-de.ts
+++ b/translations/harbour-org.gpodder.sailfish-de.ts
@@ -97,42 +97,42 @@
EpisodeItem
-
+
Pause
-
+
Abspielen
-
+
-
+
-
+
-
+
-
+
-
+
Shownotes
@@ -512,35 +512,40 @@
SettingsPage
-
+
Über
-
+
Einstellungen
-
+
YouTube
-
+
API Schlüssel (v3)
-
+
Grenzen
-
+
Maximale Anzahl Episoden pro Feed
+
+
+
+
+
SleepTimerDialog
diff --git a/translations/harbour-org.gpodder.sailfish-es.ts b/translations/harbour-org.gpodder.sailfish-es.ts
index 859d315..a0be8af 100644
--- a/translations/harbour-org.gpodder.sailfish-es.ts
+++ b/translations/harbour-org.gpodder.sailfish-es.ts
@@ -97,44 +97,44 @@
EpisodeItem
-
+
- Pausar
+ Pausar
-
+
- Reproducir
+ Reproducir
-
+
- Descargar
+
-
+
- En cola
+
-
+
- Borrar
+
-
+
- Borrando
+
-
+
- Nuevo
+
-
+
- Notas
+ Notas
@@ -512,35 +512,40 @@
SettingsPage
-
+
Acerca de
-
+
Ajustes
-
+
YouTube
-
+
Clave API (v3)
-
+
Límites
-
+
Núm. máximo de episodios por canal
+
+
+
+
+
SleepTimerDialog
diff --git a/translations/harbour-org.gpodder.sailfish-it.ts b/translations/harbour-org.gpodder.sailfish-it.ts
index e381673..a0c3a75 100644
--- a/translations/harbour-org.gpodder.sailfish-it.ts
+++ b/translations/harbour-org.gpodder.sailfish-it.ts
@@ -97,42 +97,42 @@
EpisodeItem
-
+
Pausa
-
+
Riproduci
-
+
-
+
-
+
-
+
-
+
-
+
Note
@@ -512,35 +512,40 @@
SettingsPage
-
+
Info
-
+
Impostazioni
-
+
YouTube
-
+
API Key (v3)
-
+
Limiti
-
+
Massimo episodi per feed
+
+
+
+
+
SleepTimerDialog
diff --git a/translations/harbour-org.gpodder.sailfish-pl.ts b/translations/harbour-org.gpodder.sailfish-pl.ts
index b0d0fca..9a0ffdd 100644
--- a/translations/harbour-org.gpodder.sailfish-pl.ts
+++ b/translations/harbour-org.gpodder.sailfish-pl.ts
@@ -97,42 +97,42 @@
EpisodeItem
-
+
- Pauza
+ Pauza
-
+
- Odtwarzaj
+ Odtwarzaj
-
+
- Pobierz
+
-
+
- Kolejkuj
+
-
+
- Usuń
+
-
+
- Usuwanie
+
-
+
-
+
Opis odcinka
@@ -512,35 +512,40 @@
SettingsPage
-
+
O gPodder
-
+
Ustawienia
-
+
YouTube
-
+
Klucz API (v3)
-
+
Limity
-
+
Maksymalna liczba odcinków na kanał
+
+
+
+
+
SleepTimerDialog
diff --git a/translations/harbour-org.gpodder.sailfish-ru.ts b/translations/harbour-org.gpodder.sailfish-ru.ts
index 07beb1f..44bb05d 100644
--- a/translations/harbour-org.gpodder.sailfish-ru.ts
+++ b/translations/harbour-org.gpodder.sailfish-ru.ts
@@ -97,44 +97,44 @@
EpisodeItem
-
+
- Пауза
+ Пауза
-
+
- Играть
+ Играть
-
+
- Скачать
+
-
+
- В очередь
+
-
+
- Удалить
+
-
+
- Удаление
+
-
+
- Отмечать как новый
+
-
+
- Описание
+ Описание
@@ -512,35 +512,40 @@
SettingsPage
-
+
О программе
-
+
Настройка
-
+
YouTube
-
+
Ключ API (версия 3)
-
+
Ограничения
-
+
Максимальное число выпусков
+
+
+
+
+
SleepTimerDialog
diff --git a/translations/harbour-org.gpodder.sailfish-sv.ts b/translations/harbour-org.gpodder.sailfish-sv.ts
index 88179c8..99e8c2b 100644
--- a/translations/harbour-org.gpodder.sailfish-sv.ts
+++ b/translations/harbour-org.gpodder.sailfish-sv.ts
@@ -97,44 +97,44 @@
EpisodeItem
-
+
- Paus
+ Pause
-
+
- Spela
+ Spela
-
+
- Ladda ner
+
-
+
- Köa
+
-
+
- Ta bort
+
-
+
- Tar bort
+
-
+
- Ny av/på
+
-
+
- Visa notiser
+ Show notes
@@ -512,35 +512,40 @@
SettingsPage
-
+
Om
-
+
Inställningar
-
+
YouTube
-
+
API-nyckel (v3)
-
+
Begränsningar
-
+
Max antal avsnitt per flöde
+
+
+
+
+
SleepTimerDialog
diff --git a/translations/harbour-org.gpodder.sailfish-zh_CN.ts b/translations/harbour-org.gpodder.sailfish-zh_CN.ts
index 8a562de..431044a 100644
--- a/translations/harbour-org.gpodder.sailfish-zh_CN.ts
+++ b/translations/harbour-org.gpodder.sailfish-zh_CN.ts
@@ -97,44 +97,44 @@
EpisodeItem
-
+
- 暂停
+ 暂停
-
+
- 播放
+ 播放
-
+
- 下载
+
-
+
- 队列
+
-
+
- 删除
+
-
+
- 删除中
+
-
+
- 切到新的
+
-
+
- 剧集说明
+ 剧集说明
@@ -512,35 +512,40 @@
SettingsPage
-
+
关于
-
+
设置
-
+
YouTube
-
+
API 密钥(v3)
-
+
限制
-
+
每个订阅流的最大剧集
+
+
+
+
+
SleepTimerDialog
diff --git a/translations/harbour-org.gpodder.sailfish.ts b/translations/harbour-org.gpodder.sailfish.ts
index 0cae0ee..fb2806b 100644
--- a/translations/harbour-org.gpodder.sailfish.ts
+++ b/translations/harbour-org.gpodder.sailfish.ts
@@ -97,42 +97,42 @@
EpisodeItem
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -512,35 +512,40 @@
SettingsPage
-
+
-
+
-
+
-
+
-
+
-
+
+
+
+
+
+
SleepTimerDialog