Navigation Menu

Skip to content

Commit

Permalink
[sociald] Implemented subpages for social media feeds. Contributes to…
Browse files Browse the repository at this point in the history
… JB#2551
  • Loading branch information
Antti Seppälä committed Oct 10, 2013
1 parent 28b3699 commit 4a18317
Show file tree
Hide file tree
Showing 21 changed files with 630 additions and 171 deletions.
10 changes: 8 additions & 2 deletions rpm/sociald.spec
Expand Up @@ -55,10 +55,16 @@ A daemon process which provides data synchronization with various social service
%{_datadir}/translations/sociald_eng_en.qm
%{_datadir}/translations/lipstick-jolla-home-facebook_eng_en.qm
%{_datadir}/translations/lipstick-jolla-home-twitter_eng_en.qm
%{_datadir}/lipstick/eventfeed/facebook.qml
%{_datadir}/lipstick/eventfeed/FacebookPostPage.qml
%{_datadir}/lipstick/eventfeed/facebook-update.qml
%{_datadir}/lipstick/eventfeed/twitter.qml
%{_datadir}/lipstick/eventfeed/facebook-delegate.qml
%{_datadir}/lipstick/eventfeed/FacebookFeedItem.qml
%{_datadir}/lipstick/eventfeed/FacebookFeedPage.qml
%{_datadir}/lipstick/eventfeed/TwitterPostPage.qml
%{_datadir}/lipstick/eventfeed/twitter-update.qml
%{_datadir}/lipstick/eventfeed/twitter-delegate.qml
%{_datadir}/lipstick/eventfeed/TwitterFeedItem.qml
%{_datadir}/lipstick/eventfeed/TwitterFeedPage.qml
%{_datadir}/lipstick/eventfeed/shared/*.qml

%package ts-devel
Expand Down
31 changes: 12 additions & 19 deletions src/eventfeed/SocialAccountPullDownMenu.qml
Expand Up @@ -6,37 +6,29 @@ PullDownMenu {
id: container
property int currentAccount
property int currentAccountIndex: -1
property var metaData
property string selectAccountString
property string changeToAccountString
property string accountString
property var pageContainer
property string serviceName
property bool switchEnabled
onMetaDataChanged: refreshAccountList()

// We distinguish internal.index and container.currentAccountIndex
// It is because internal.accounts is not matching the accounts
// data carried by the metadata. This is because accounts might
// got deleted between two sync, and that metadata contains
// data that should not exist.
//
// internal.index stores the index of the current account in
// internal.account, while container.currentAccountIndex
// is used to store the index for the metadata. If metadata
// carries also information for (for example) avatar, that
// are indexed, then container.currentAccountIndex contains
// the good index, even if accounts got removed
function refreshAccountList() {
var subviewAccounts = subviewModel.accountList(serviceName)
internal.accounts = []
for (var i = 0; i < container.metaData["accountIdCount"]; i++) {
for (var i = 0; i < subviewAccounts.length; ++i) {
var accountData = new Object
accountData["id"] = container.metaData["accountId" + i]
var account = accountManager.account(accountData["id"])
if (account != null) {
accountData["name"] = account.displayName
accountData["index"] = i
internal.accounts.push(accountData)
}
var account = subviewAccounts[i]
accountData["id"] = account.identifier
accountData["name"] = account.displayName
accountData["index"] = internal.accounts.length
internal.accounts.push(accountData)
}
internal.accountCount = internal.accounts.length
container.currentAccount = internal.accounts[0]["id"]
Expand All @@ -54,9 +46,6 @@ PullDownMenu {
property var accounts
property int index
property int otherIndex
},
AccountManager {
id: accountManager
}
]

Expand Down Expand Up @@ -91,4 +80,8 @@ PullDownMenu {
MenuLabel {
text: container.accountString.arg(internal.accounts[internal.index]["name"])
}

Component.onCompleted: {
refreshAccountList()
}
}
33 changes: 9 additions & 24 deletions src/eventfeed/SocialAvatar.qml
@@ -1,37 +1,22 @@
import QtQuick 2.0
import Sailfish.Silica 1.0

Item {
id: container
property string icon
Image {
id: image
width: Theme.itemSizeExtraLarge
height: Theme.itemSizeExtraLarge
asynchronous: true
fillMode: Image.PreserveAspectCrop
sourceSize {
width: image.width
height: image.height
}

Rectangle {
anchors.fill: parent
color: Theme.highlightColor
opacity: 0.5
}

Image {
anchors.fill: parent
sourceSize {
width: container.width
height: container.height
}
asynchronous: true
fillMode: Image.PreserveAspectCrop
source: {
if (container.icon == "") {
return container.icon
} else if (container.icon.indexOf("http") == 0) {
return container.icon
} else if (container.icon.indexOf("/") == 0) {
return "image://nemoThumbnail/" + container.icon
} else {
return "image://theme/" + container.icon
}
}
visible: image.status !== Image.Ready
}
}

1 change: 1 addition & 0 deletions src/eventfeed/SocialButton.qml
Expand Up @@ -25,5 +25,6 @@ MouseArea {
}
color: container.pressed ? Theme.highlightColor : Theme.primaryColor
opacity: container.enabled ? 1 : 0.5
font.pixelSize: Theme.fontSizeSmall
}
}
8 changes: 2 additions & 6 deletions src/eventfeed/SocialContent.qml
Expand Up @@ -3,7 +3,7 @@ import Sailfish.Silica 1.0

Item {
id: container
property alias avatar: socialAvatar.icon
property alias avatar: socialAvatar.source
property alias source: header.title
property date timestamp
property alias body: body.text
Expand All @@ -16,10 +16,6 @@ Item {
right: parent.right
}

Formatter {
id: formatter
}

Rectangle {
anchors.fill: parent
color: Theme.highlightColor
Expand All @@ -45,7 +41,7 @@ Item {
rightMargin: Theme.paddingLarge
}

time: formatter.formatDate(container.timestamp, Formatter.DurationElapsed)
time: Format.formatDate(container.timestamp, Formatter.DurationElapsed)
}

// This item is used to anchors social buttons and full-row social buttons content
Expand Down
39 changes: 39 additions & 0 deletions src/eventfeed/SocialMediaAccountDelegate.qml
@@ -0,0 +1,39 @@
import QtQuick 2.0
import Sailfish.Silica 1.0

BackgroundItem {
width: parent.width
height: Theme.itemSizeLarge

property Page feedPage
property Item subviewModel
property alias iconSource: icon.source

onClicked: {
pageStack.push(feedPage)
feedPage.positionViewAtBeginning()
}

Rectangle {
anchors.fill: parent
gradient: Gradient {
GradientStop { position: 0; color: Theme.rgba(Theme.highlightColor, 0) }
GradientStop { position: 1; color: Theme.rgba(Theme.highlightColor, 0.2) }
}
}

Image {
id: icon
anchors {
verticalCenter: parent.verticalCenter
right: parent.right
rightMargin: Theme.paddingLarge
}
width: parent.height / 2
height: width
}

function sync() {
feedPage.sync()
}
}
28 changes: 28 additions & 0 deletions src/eventfeed/SocialMediaFeedItem.qml
@@ -0,0 +1,28 @@
import QtQuick 2.0
import Sailfish.Silica 1.0

BackgroundItem {
property string timestamp: model.timestamp
property string formattedTime
property SocialAvatar avatar: _avatar

onTimestampChanged: formatTime()

SocialAvatar {
id: _avatar
source: model.icon
width: Theme.itemSizeMedium
height: Theme.itemSizeMedium
}

Connections {
target: refreshTimer
onTriggered: formatTime()
}

function formatTime() {
formattedTime = Format.formatDate(timestamp, Formatter.DurationElapsed)
}

Component.onCompleted: formatTime()
}
59 changes: 59 additions & 0 deletions src/eventfeed/SocialMediaFeedPage.qml
@@ -0,0 +1,59 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
import org.nemomobile.socialcache 1.0

Page {
id: page

property alias listModel: _listView.model
property alias listDelegate: _listView.delegate
property alias socialNetwork: syncHelper.socialNetwork
property string headerTitle
property SilicaListView listView: _listView

signal refreshTime

onVisibleChanged: {
if (visible && status === PageStatus.Active) {
page.refreshTime()
}
}

onStatusChanged: {
if (status === PageStatus.Active) {
page.refreshTime()
}
}

SyncHelper {
id: syncHelper
socialNetwork: SocialSync.Twitter
dataType: SocialSync.Posts
onLoadingChanged: {
if (!loading && page.listModel) {
page.listModel.refresh()
}
}
}

SilicaListView {
id: _listView
anchors.fill: parent
cacheBuffer: Screen.height * 4
header: PageHeader {
title: page.headerTitle
}

VerticalScrollDecorator {}
}

function sync() {
syncHelper.sync()
}

function positionViewAtBeginning() {
_listView.positionViewAtBeginning()
}

Component.onCompleted: sync()
}
28 changes: 10 additions & 18 deletions src/eventfeed/SocialMediaRow.qml
@@ -1,5 +1,6 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
import Sailfish.TextLinking 1.0

Item {
id: container
Expand Down Expand Up @@ -45,17 +46,7 @@ Item {
}
asynchronous: true
fillMode: Image.PreserveAspectCrop
source: {
if (container.imageList[index] == "") {
return container.imageList[index]
} else if (container.imageList[index].indexOf("http") == 0) {
return container.imageList[index]
} else if (container.imageList[index].indexOf("/") == 0) {
return "image://nemoThumbnail/" + container.imageList[index]
} else {
return "image://theme/" + container.imageList[index]
}
}
source: model.modelData.url
}
}

Expand All @@ -64,7 +55,7 @@ Item {
height: repeater.imageSize
visible: container.imageList.length === 1

Label {
LinkedText {
anchors {
top: parent.top
topMargin: Theme.paddingMedium
Expand All @@ -75,13 +66,15 @@ Item {
bottom: caption.top
bottomMargin: Theme.paddingSmall
}
text: container.mediaName
font.pixelSize: Theme.fontSizeSmall
plainText: container.mediaName
font.pixelSize: Theme.fontSizeExtraSmall
wrapMode: Text.WordWrap
elide: Text.ElideRight
shortenUrl: true
opacity: .6
}

Label {
LinkedText {
id: caption
anchors {
bottom: parent.bottom
Expand All @@ -91,15 +84,14 @@ Item {
right: parent.right
rightMargin: Theme.paddingMedium
}
text: container.mediaCaption
plainText: container.mediaCaption
color: Theme.highlightColor
font.pixelSize: Theme.fontSizeExtraSmall
wrapMode: Text.WordWrap
elide: Text.ElideRight
maximumLineCount: 1
shortenUrl: true
}
}
}
}


9 changes: 9 additions & 0 deletions src/eventfeed/SocialReplyField.qml
Expand Up @@ -8,12 +8,19 @@ Item {
property alias placeholderText: textField.placeholderText
property alias text: textField.text
property alias allowComment: textField.enabled
property alias errorHighlight: textField.errorHighlight
property alias label: textField.label
signal enterKeyClicked()

function forceActiveFocus() {
textField.forceActiveFocus()
}

function close() {
textField.focus = false
textField.text = ""
}

function clear() {
textField.text = ""
}
Expand Down Expand Up @@ -53,6 +60,8 @@ Item {
right: parent.right
}

EnterKey.highlighted: text.length > 0
EnterKey.iconSource: "image://theme/icon-m-enter-" + (text.length > 0 ? "accept" : "close")
EnterKey.onClicked: {
container.enterKeyClicked()
}
Expand Down

0 comments on commit 4a18317

Please sign in to comment.