diff --git a/harbour-tooter.pro b/harbour-tooter.pro index 4ef59a9..88c2be7 100644 --- a/harbour-tooter.pro +++ b/harbour-tooter.pro @@ -43,7 +43,9 @@ CONFIG += sailfishapp_i18n # planning to localize your app, remember to comment out the # following TRANSLATIONS line. And also do not forget to # modify the localized app name in the the .desktop file. -TRANSLATIONS += translations/harbour-tooter-de.ts +TRANSLATIONS += \ + translations/harbour-tooter-fr.ts \ + translations/harbour-tooter-oc.ts DISTFILES += \ qml/lib/API.js \ diff --git a/harbour-tooter.pro.user b/harbour-tooter.pro.user index f2c53ae..5f6b490 100644 --- a/harbour-tooter.pro.user +++ b/harbour-tooter.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -8,7 +8,7 @@ ProjectExplorer.Project.ActiveTarget - 0 + 1 ProjectExplorer.Project.EditorSettings @@ -414,7 +414,7 @@ 3768 false true - false + true false true diff --git a/icons/108x108/harbour-tooter.png b/icons/108x108/harbour-tooter.png index ab10628..c500c5e 100644 Binary files a/icons/108x108/harbour-tooter.png and b/icons/108x108/harbour-tooter.png differ diff --git a/icons/128x128/harbour-tooter.png b/icons/128x128/harbour-tooter.png index 54375c5..bb7751d 100644 Binary files a/icons/128x128/harbour-tooter.png and b/icons/128x128/harbour-tooter.png differ diff --git a/icons/256x256/harbour-tooter.png b/icons/256x256/harbour-tooter.png index de79583..765dd66 100644 Binary files a/icons/256x256/harbour-tooter.png and b/icons/256x256/harbour-tooter.png differ diff --git a/icons/86x86/harbour-tooter.png b/icons/86x86/harbour-tooter.png index ad316d6..0ad7dfd 100644 Binary files a/icons/86x86/harbour-tooter.png and b/icons/86x86/harbour-tooter.png differ diff --git a/qml/harbour-tooter.qml b/qml/harbour-tooter.qml index 0c744ca..68c883d 100644 --- a/qml/harbour-tooter.qml +++ b/qml/harbour-tooter.qml @@ -31,6 +31,7 @@ import QtQuick 2.0 import Sailfish.Silica 1.0 import "pages" +import org.nemomobile.notifications 1.0 import "./lib/API.js" as Logic ApplicationWindow diff --git a/qml/lib/Worker.js b/qml/lib/Worker.js index 793019c..2698d56 100644 --- a/qml/lib/Worker.js +++ b/qml/lib/Worker.js @@ -25,17 +25,18 @@ WorkerScript.onMessage = function(msg) { API.get(msg.action, msg.params, function(data) { var items = []; for (var i in data) { + var item; if (data.hasOwnProperty(i)) { if(msg.action === "accounts/search") { - var item = parseAccounts(data[i]); + item = parseAccounts(data[i]); items.push(item) } else if(msg.action === "notifications") { console.log("Is notification... parsing...") - var item = parseNotification(data[i]); + item = parseNotification(data[i]); items.push(item) } else if (data[i].hasOwnProperty("content")){ console.log("Is toot... parsing...") - var item = parseToot(data[i]); + item = parseToot(data[i]); item['id'] = item['status_id'] items.push(item) } else { @@ -83,13 +84,15 @@ function parseNotification(data){ var item = { id: data.id, type: data.type, - created_at: new Date(data.created_at) + created_at: new Date(data.created_at), + section: new Date(data["created_at"]).toLocaleDateString() }; switch (item['type']){ case "mention": item = parseToot(data.status) item['typeIcon'] = "image://theme/icon-s-retweet" item['typeIcon'] = "image://theme/icon-s-alarm" + item['type'] = "mention"; break; case "reblog": item = parseToot(data.status) @@ -122,6 +125,8 @@ function parseNotification(data){ item['id'] = data.id + //WorkerScript.sendMessage({ 'fireNotification': true, "data": item}) + return item; } @@ -147,6 +152,7 @@ function parseToot (data){ item['status_reblog'] = data["reblog"] ? true : false item['status_content'] = data["content"] item['status_created_at'] = item['created_at'] = new Date(data["created_at"]); + item['section'] = new Date(data["created_at"]).toLocaleDateString() item['status_reblogs_count'] = data["reblogs_count"] item['status_favourites_count'] = data["favourites_count"] item['status_reblogged'] = data["reblogged"] @@ -172,56 +178,7 @@ function parseToot (data){ //item['application_name'] = data["application"]["name"] //item['application_website'] = data["application"]["website"] // account - /* - - - */ - - - - - - /*item['type'] = ""; - item['retweetScreenName'] = ''; - item['isVerified'] = false; - item['isReblog'] = false; - item['favourited'] = data['favourited']; - item['reblogged'] = data['reblogged']; - item['muted'] = data['muted']; - item['status_reblogs_count'] = data['reblogs_count']; - item['status_favourites_count'] = data['favourites_count']; - - if(data['id']){ - item['status_id'] = data['id']; - } - if(data['created_at']){ - item['status_created_at'] = data['created_at']; - } - if(data['account']){ - item['status_account_id'] = data['account']['id']; - item['status_account_username'] = data['account']['acct']; - item['status_account_display_name'] = data['account']['display_name']; - item['status_account_locked'] = data['account']['locked']; - item['status_account_avatar'] = data['account']['avatar']; - } - if(data['reblog']){ - item['retweetScreenName'] = data['account']['username']; - item['type'] = "reblog"; - item['reblog_id'] = data['reblog']['id']; - item['account_id'] = data['reblog']['account']['id']; - item['account_username'] = data['reblog']['account']['username']; - item['account_display_name'] = data['reblog']['account']['display_name']; - item['account_locked'] = data['reblog']['account']['locked']; - item['account_avatar'] = data['reblog']['account']['avatar']; - - item['status_reblogs_count'] = data['reblog']['reblogs_count']; - item['status_favourites_count'] = data['reblog']['favourites_count']; - item['status_favourited'] = data['reblog']['favourited']; - item['status_reblogged'] = data['reblog']['reblogged']; - item['status_muted'] = data['reblog']['muted']; - } - */ item['content'] = data['content'].replace(/(<([^>]+)>)/ig,""); /*for(var i = 0; i < data['tags'].length ; i++){ var tag = data['tags'][i]['name']; @@ -240,7 +197,7 @@ function parseToot (data){ } item['content'] = item['content'].join(" ").autoLink() - console.log(JSON.stringify(item)) + //console.log(JSON.stringify(item)) return item; } diff --git a/qml/pages/Conversation.qml b/qml/pages/Conversation.qml index 190d6a5..48ef7f2 100644 --- a/qml/pages/Conversation.qml +++ b/qml/pages/Conversation.qml @@ -129,4 +129,7 @@ Page { } } } + Component.onCompleted: { + toot.cursorPosition = toot.text.length + } } diff --git a/qml/pages/MainPage.qml b/qml/pages/MainPage.qml index 352bfd9..545b07b 100644 --- a/qml/pages/MainPage.qml +++ b/qml/pages/MainPage.qml @@ -80,6 +80,7 @@ Page { id: tlNotifications; title: qsTr("Notifications") type: "notifications" + notifier: true mdl: Logic.modelTLnotifications width: parent.width height: parent.height diff --git a/qml/pages/components/MyList.qml b/qml/pages/components/MyList.qml index 375b405..f578116 100644 --- a/qml/pages/components/MyList.qml +++ b/qml/pages/components/MyList.qml @@ -2,9 +2,20 @@ import QtQuick 2.0 import Sailfish.Silica 1.0 import "../../lib/API.js" as Logic import "." +import org.nemomobile.notifications 1.0 SilicaListView { + + + + Notification { + id: notification + category: "x-nemo.example" + urgency: Notification.Normal + onClicked: console.log("Clicked") + } + id: myList property string type; property string title @@ -17,6 +28,7 @@ SilicaListView { property string action: "" property variant vars property variant conf + property bool notifier : false; model: mdl signal notify (string what, int num) onNotify: { @@ -63,10 +75,6 @@ SilicaListView { Logic.conf['instance'] = null; Logic.conf['api_user_token'] = null; Logic.conf['dysko'] = null; - } else { - Logic.conf['login'] = true - Logic.conf['instance'] = "https://mastodon.social"; - Logic.conf['api_user_token'] = '6d8cb23e3ebf3c7a97dd9adf204e47ad159f1a3d07dbbd0325e98981368d8c51'; } } } @@ -89,21 +97,8 @@ SilicaListView { clip: true section { property: 'section' - criteria: ViewSection.FullString delegate: SectionHeader { - text: { - var dat = Date.fromLocaleDateString(locale, created_at); - dat = Format.formatDate(dat, Formatter.TimepointRelativeCurrentDay) - if (dat === "00:00:00" || dat === "00:00") { - visible = false; - height = 0; - return " "; - }else { - return dat; - } - - } - + text: section } } @@ -146,9 +141,55 @@ SilicaListView { if (messageObject.error){ console.log(JSON.stringify(messageObject)) } - if (messageObject.notifyNewItems){ - console.log(JSON.stringify(messageObject.notifyNewItems)) + if (messageObject.fireNotification && notifier){ + console.log(JSON.stringify(messageObject.data.id)) + var item = messageObject.data + item.content = item.content.replace(/(<([^>]+)>)/ig,"").replaceAll(""", "\"") + if(notification.replacesId){ + notification.replacesId = 0 + } + + switch (item.type){ + case "favourite": + notification.urgency = Notification.Normal + notification.timestamp = item.created_at + notification.summary = (item.reblog_account_display_name !== "" ? item.reblog_account_display_name : '@'+item.reblog_account_username) + ' ' + qsTr("favourited") + notification.body = item.content + notification.publish() + break; + case "follow": + notification.urgency = Notification.Critical + notification.timestamp = item.created_at + notification.summary = (item.account_display_name !== "" ? item.account_display_name : '@'+item.account_acct) + notification.body = qsTr("followed you") + notification.publish() + break; + + case "reblog": + notification.urgency = Notification.Low + notification.timestamp = item.created_at + notification.summary = (item.account_display_name !== "" ? item.account_display_name : '@'+item.account_acct) + ' ' + qsTr("boosted") + notification.body = item.content + notification.publish() + break; + case "mention": + notification.urgency = Notification.Critical + notification.timestamp = item.created_at + notification.summary = (item.account_display_name !== "" ? item.account_display_name : '@'+item.account_acct) + ' ' + qsTr("said") + notification.previewSummary = notification.summary + notification.body = item.content + notification.previewBody = notification.body + notification.publish() + break; + default: + console.log(JSON.stringify(messageObject.data)) + break; + } + + + } + } } @@ -162,6 +203,14 @@ SilicaListView { }; worker.sendMessage(msg); } + + Timer { + triggeredOnStart: true; interval: 5*60*1000; running: true; repeat: true + onTriggered: { + console.log(title + ' ' +Date().toString()) + loadData("prepend") + } + } function loadData(mode){ var p = []; if (mode === "append" && model.count){ diff --git a/translations/harbour-tooter-de.ts b/translations/harbour-tooter-de.ts index 6f617b0..ed7307b 100644 --- a/translations/harbour-tooter-de.ts +++ b/translations/harbour-tooter-de.ts @@ -101,6 +101,22 @@ Load more + + boosted + + + + favourited + + + + followed you + + + + said + + Profile diff --git a/translations/harbour-tooter-fr.ts b/translations/harbour-tooter-fr.ts index 32b20fc..82a7e96 100644 --- a/translations/harbour-tooter-fr.ts +++ b/translations/harbour-tooter-fr.ts @@ -41,7 +41,7 @@ unlisted non-listé - + followers only abonnés uniquement @@ -80,12 +80,43 @@ Nouveau pouet + + MiniStatus + + boosted + a partagé + + + favourited + a ajouté à ses favoris + + + followed you + vous suit + + MyList Load more Charger davantage + + favourited + a ajouté à ses favoris + + + followed you + vous suit + + + boosted + a partagé + + + said + + Profile diff --git a/translations/harbour-tooter-oc.ts b/translations/harbour-tooter-oc.ts index ca17d23..2e46892 100644 --- a/translations/harbour-tooter-oc.ts +++ b/translations/harbour-tooter-oc.ts @@ -80,12 +80,43 @@ Nòu tut + + MiniStatus + + boosted + a tornat partejar + + + favourited + a mes en favorit + + + followed you + vos sèc + + MyList Load more Cargar mai + + favourited + a mes en favorit + + + followed you + vos sèc + + + boosted + a tornat partejar + + + said + + Profile diff --git a/translations/harbour-tooter.ts b/translations/harbour-tooter.ts index aa28688..36d25d4 100644 --- a/translations/harbour-tooter.ts +++ b/translations/harbour-tooter.ts @@ -77,11 +77,30 @@ New Toot - + New MiniStatus + + boosted + boosted + + + favourited + favourited + + + followed you + followed you + + + + MyList + + Load more + Load more + boosted boosted @@ -94,12 +113,9 @@ followed you followed you - - - MyList - Load more - Load more + said +