Misc update

- User and tag  search improvement
- Added visual hints
- User prediction added
This commit is contained in:
Dusko Angirevic 2017-11-01 00:27:48 +01:00
parent 10f27b9d50
commit f4150c47fc
16 changed files with 320 additions and 163 deletions

View file

@ -56,7 +56,6 @@ WorkerScript.onMessage = function(msg) {
item = parseAccounts([], "", data[i]);
console.log(JSON.stringify(data[i]))
items.push(item)
console.log("aaaa")
} else if(msg.action === "notifications") {
// notification
@ -229,9 +228,6 @@ function parseToot (data){
item['status_visibility'] = data["visibility"]
//item.concat(parseAccounts("", data["account"]));
//item = collect(item, );
if(item['status_reblog']){
item['type'] = "reblog";
item['typeIcon'] = "image://theme/icon-s-retweet"
@ -241,19 +237,8 @@ function parseToot (data){
item = parseAccounts(item, "", data["account"])
}
item['content'] = data['content'].replaceAll('</span><span class="invisible">', '').replaceAll('<span class="invisible">', '').replaceAll('</span><span class="ellipsis">', '');
//item['application_name'] = data["application"]["name"]
//item['application_website'] = data["application"]["website"]
// account
//item['content'] = data['content'].replace(/(<([^>]+)>)/ig,"");
/*for(var i = 0; i < data['tags'].length ; i++){
var tag = data['tags'][i]['name'];
console.log(tag)
item['content'] = item['content'].replaceAll('#'+tag, '<a href="#'+tag+'">'+tag+'</a>')
}*/
item['attachments'] = [];
//console.log("Image "+loadImages)
for(var i = 0; i < data['media_attachments'].length ; i++){
var attachments = data['media_attachments'][i];
@ -265,25 +250,12 @@ function parseToot (data){
url: attachments['remote_url'] && typeof attachments['remote_url'] == "string" ? attachments['remote_url'] : attachments['url'] ,
preview_url: loadImages ? attachments['preview_url'] : ''
}
console.log("-----------------------------------")
console.log(JSON.stringify(attachments))
console.log(typeof attachments['remote_url'])
console.log(JSON.stringify(tmp))
console.log("-----------------------------------")
//console.log("-----------------------------------")
//console.log(JSON.stringify(attachments))
//console.log(typeof attachments['remote_url'])
//console.log(JSON.stringify(tmp))
//console.log("-----------------------------------")
item['attachments'].push(tmp)
}
/*item['content'] = item['content'].split(" ")
for(var i = 0; i < item['content'].length ; i++){
if(item['content'][i][0] === "#"){
item['content'][i] = '<a href="'+item['content'][i]+'">'+item['content'][i]+'</a>';
}
if(item['content'][i][0] === "@"){
item['content'][i] = '<a href="'+item['content'][i]+'">'+item['content'][i]+'</a>';
}
}
item['content'] = item['content'].join(" ").autoLink()*/
//console.log(JSON.stringify(item))
return item;
}

View file

@ -109,7 +109,7 @@ Page {
textOperations.cursorPosition = toot.cursorPosition
textOperations.moveCursorSelection(start-1,TextInput.SelectWords)
toot.text = textOperations.text.substring(0, textOperations.selectionStart) + ' @'+model.account_acct + ' ' + textOperations.text.substring(textOperations.selectionEnd).trim()
textOperations.text = ""
toot.cursorPosition = toot.text.indexOf('@'+model.account_acct)
}
}
@ -177,7 +177,7 @@ Page {
textOperations.cursorPosition = toot.cursorPosition
textOperations.selectWord()
textOperations.select(textOperations.selectionStart ? textOperations.selectionStart-1 : 0, textOperations.selectionEnd)
console.log(textOperations.text.substr(textOperations.selectionStart, textOperations.selectionEnd))
//console.log(textOperations.text.substr(textOperations.selectionStart, textOperations.selectionEnd))
suggestedUser = ""
if (textOperations.selectedText.charAt(0) === "@") {
suggestedUser = textOperations.selectedText.trim().substring(1);

View file

@ -87,52 +87,112 @@ Page {
height: parent.itemHeight
onOpenDrawer: infoPanel.open = setDrawer
}
MyList{
Item {
id: tlSearch;
property string search;
onSearchChanged: {
mdl = Qt.createQmlObject('import QtQuick 2.0; ListModel { }', Qt.application, 'InternalQmlObject');
if (search[0] === "#") {
tlSearch.type = "timelines/tag/"+search.substring(1)
loadData("append")
}
if (search[0] === "@") {
tlSearch.type = "accounts/search"
tlSearch.params = []
tlSearch.params.push({name: 'q', data: search.substring(1)});
loadData("append")
}
}
onTypeChanged: {
console.log("type changed")
}
title: qsTr("Search")
type: ""
mdl: ListModel {}
width: parent.itemWidth
height: parent.itemHeight
onOpenDrawer: infoPanel.open = setDrawer
header: SearchField {
width: parent.width
text: tlSearch.search
placeholderText: "Search"
labelVisible: false
EnterKey.iconSource: "image://theme/icon-m-enter-close"
EnterKey.onClicked: {
tlSearch.search = text
focus = false
property ListModel mdl: ListModel {}
property string search;
onSearchChanged: {
console.log(search)
loader.sourceComponent = loading
if (search !== ""){
loader.sourceComponent = search.charAt(0) === "@" ? userListComponent : tagListComponent
}
}
ViewPlaceholder {
enabled: tlSearch.mdl === 0
text: "Only #hastag search works"
}
delegate: Loader {
width: parent.width
source: tlSearch.search[0] === "@" ? "components/ItemUser.qml" : "components/VisualContainer.qml"
Loader {
id: loader
anchors.fill: parent
}
Column {
id: headerContainer
width: tlSearch.width
PageHeader {
title: qsTr("Search")
}
SearchField {
id: searchField
width: parent.width
placeholderText: qsTr("@user or #term")
text: tlSearch.search
EnterKey.iconSource: "image://theme/icon-m-enter-close"
EnterKey.onClicked: {
tlSearch.search = text.toLowerCase().trim()
focus = false
console.log(text)
}
}
}
Component {
id: loading
BusyIndicator {
size: BusyIndicatorSize.Large
anchors.centerIn: parent
running: true
}
}
Component {
id: tagListComponent
MyList {
id: view
mdl: ListModel {}
width: parent.width
height: parent.height
onOpenDrawer: infoPanel.open = setDrawer
anchors.fill: parent
currentIndex: -1 // otherwise currentItem will steal focus
header: Item {
id: header
width: headerContainer.width
height: headerContainer.height
Component.onCompleted: headerContainer.parent = header
}
delegate: VisualContainer
Component.onCompleted: {
view.type = "timelines/tag/"+tlSearch.search.substring(1)
view.loadData("append")
}
}
}
Component {
id: userListComponent
MyList {
id: view2
mdl: ListModel {}
autoLoadMore: false
width: parent.width
height: parent.height
onOpenDrawer: infoPanel.open = setDrawer
anchors.fill: parent
currentIndex: -1 // otherwise currentItem will steal focus
header: Item {
id: header
width: headerContainer.width
height: headerContainer.height
Component.onCompleted: headerContainer.parent = header
}
delegate: ItemUser {
onClicked: {
pageStack.push(Qt.resolvedUrl("Profile.qml"), {
"displayname": model.account_username,
"username": model.account_acct,
"user_id": model.account_id,
"profileImage": model.account_avatar
})
}
}
Component.onCompleted: {
view2.type = "accounts/search"
view2.params = []
view2.params.push({name: 'q', data: tlSearch.search.substring(1)});
view2.loadData("append")
}
}
}
}
}

View file

@ -38,7 +38,7 @@ Page {
user_id = messageObject.data.id
followers_count = messageObject.data.followers_count
following_count = messageObject.data.following_count
username = messageObject.data.username
username = messageObject.data.acct
displayname = messageObject.data.display_name
profileImage = messageObject.data.avatar_static
@ -68,7 +68,7 @@ Page {
following_count = messageObject.data
break;
case 'acct':
username = messageObject.data
//username = messageObject.data
break;
case 'locked':
locked = messageObject.data
@ -106,6 +106,7 @@ Page {
allowedOrientations: Orientation.All
Component.onCompleted: {
var msg;
if (user_id) {
msg = {
'action' : "accounts/relationships/",
@ -119,8 +120,9 @@ Page {
};
worker.sendMessage(msg);
} else {
var instance = Logic.conf['instance'].split("//")
msg = {
'action' : "accounts/search?limit=1&q="+username,
'action' : "accounts/search?limit=1&q="+username.replace("@"+instance[1], ""),
'conf' : Logic.conf
};
worker.sendMessage(msg);

View file

@ -1,21 +1,35 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
import QtGraphicalEffects 1.0
BackgroundItem {
id: delegate
//property string text: "0"
signal openUser (string notice)
height: Theme.itemSizeMedium
width: parent.width
Image {
Rectangle {
id: avatar
width: Theme.itemSizeExtraSmall
height: width
source: model.account_avatar
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: Theme.horizontalPageMargin
color: Theme.highlightDimmerColor
Image {
id: img
opacity: status === Image.Ready ? 1.0 : 0.0
Behavior on opacity { FadeAnimator {} }
anchors.fill: parent
source: model.account_avatar
}
BusyIndicator {
size: BusyIndicatorSize.Small
opacity: img.status === Image.Ready ? 0.0 : 1.0
Behavior on opacity { FadeAnimator {} }
running: avatar.status !== Image.Ready;
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
onClicked: pageStack.push(Qt.resolvedUrl("./../Profile.qml"), {
@ -45,4 +59,10 @@ BackgroundItem {
font.pixelSize: Theme.fontSizeExtraSmall
}
}
onClicked: openUser({
"displayname": model.account_username,
"username": model.account_acct,
"user_id": model.account_id,
"profileImage": model.account_avatar
})
}

View file

@ -7,10 +7,13 @@ SilicaListView {
id: myList
property string type;
property string title
property string vwPlaceholderText: qsTr("Loading")
property string vwPlaceholderHint: qsTr("Performing request, please wait or request something else")
property string description
property ListModel mdl: []
property variant params: []
property var locale: Qt.locale()
property bool autoLoadMore : true;
property bool loadStarted : false;
property int scrollOffset;
property string action: ""
@ -51,8 +54,8 @@ SilicaListView {
ViewPlaceholder {
id: viewPlaceHolder
enabled: model.count === 0
text: ""
hintText: ""
text: vwPlaceholderText
hintText: vwPlaceholderHint
}
PullDownMenu {
@ -70,14 +73,6 @@ SilicaListView {
}
}
}
/*PushUpMenu {
MenuItem {
text: qsTr("Load more")
onClicked: {
loadData("append")
}
}
}*/
clip: true
section {
property: 'section'
@ -107,6 +102,7 @@ SilicaListView {
}
footer: Item{
visible: autoLoadMore
width: parent.width
height: Theme.itemSizeLarge
Button {
@ -132,7 +128,7 @@ SilicaListView {
scrollOffset = contentY
}
if(contentY+height > footerItem.y && !loadStarted){
if(contentY+height > footerItem.y && !loadStarted && autoLoadMore){
loadData("append")
loadStarted = true;
}

View file

@ -136,7 +136,7 @@ BackgroundItem {
} else if (test.length === 4 && test[3][0] === "@" ) {
pageStack.push(Qt.resolvedUrl("../Profile.qml"), {
"name": "",
"username": test[3].substring(1),
"username": test[3].substring(1)+"@"+test[2],
"profileImage": ""
})
} else {
@ -275,7 +275,8 @@ BackgroundItem {
onClicked: {
var m = Qt.createQmlObject('import QtQuick 2.0; ListModel { }', Qt.application, 'InternalQmlObject');
m.append(mdl.get(index))
if (typeof mdl !== "undefined")
m.append(mdl.get(index))
pageStack.push(Qt.resolvedUrl("../Conversation.qml"), {
toot_id: status_id,
title: account_display_name,
@ -286,9 +287,7 @@ BackgroundItem {
})
}
onPressAndHold: {
console.log(model['status_sensitive'])
console.log(model['status_spoiler_text'])
console.log(model['type'])
console.log(content)
mnu.show(delegate)
}
onDoubleClicked: {

View file

@ -113,12 +113,16 @@
<source>Notifications</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>New Toot</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>New Toot</source>
<source>@user or #term</source>
<translation type="unfinished"></translation>
</message>
</context>
@ -147,6 +151,14 @@
<source>Settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Loading</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Performing request, please wait or request something else</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Profile</name>

View file

@ -103,23 +103,27 @@
<name>MainPage</name>
<message>
<source>Home</source>
<translation>Οικοσελίδα</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Timeline</source>
<translation>Γραμμή χρονοδιαγράμματος</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Notifications</source>
<translation>Ειδοποιήσεις</translation>
</message>
<message>
<source>Search</source>
<translation>Αναζήτηση</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>New Toot</source>
<translation>Νέο Toot</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>@user or #term</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
@ -147,6 +151,14 @@
<source>Settings</source>
<translation>Ρυθμίσεις</translation>
</message>
<message>
<source>Loading</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Performing request, please wait or request something else</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Profile</name>

View file

@ -103,23 +103,27 @@
<name>MainPage</name>
<message>
<source>Home</source>
<translation>Home</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Timeline</source>
<translation>Timeline</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Notifications</source>
<translation>Notifications</translation>
</message>
<message>
<source>Search</source>
<translation>Search</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>New Toot</source>
<translation>New</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>@user or #term</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
@ -147,6 +151,14 @@
<source>Settings</source>
<translation>Settings</translation>
</message>
<message>
<source>Loading</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Performing request, please wait or request something else</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Profile</name>

View file

@ -103,23 +103,27 @@
<name>MainPage</name>
<message>
<source>Home</source>
<translation>Inicio</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Timeline</source>
<translation>Historia federada</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Notifications</source>
<translation>Notificaciones</translation>
</message>
<message>
<source>Search</source>
<translation>Buscar</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>New Toot</source>
<translation>Nuevo toot</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>@user or #term</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
@ -147,6 +151,14 @@
<source>Settings</source>
<translation>Ajustes</translation>
</message>
<message>
<source>Loading</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Performing request, please wait or request something else</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Profile</name>

View file

@ -103,23 +103,27 @@
<name>MainPage</name>
<message>
<source>Home</source>
<translation>Accueil</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Timeline</source>
<translation>Chronologie</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Notifications</source>
<translation>Notifications</translation>
</message>
<message>
<source>Search</source>
<translation>Recherche</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>New Toot</source>
<translation>Nouveau</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>@user or #term</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
@ -147,6 +151,14 @@
<source>Settings</source>
<translation>Paramètres</translation>
</message>
<message>
<source>Loading</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Performing request, please wait or request something else</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Profile</name>

View file

@ -103,23 +103,27 @@
<name>MainPage</name>
<message>
<source>Home</source>
<translation>Thuis</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Timeline</source>
<translation>Tijdlijn</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Notifications</source>
<translation>Meldingen</translation>
</message>
<message>
<source>Search</source>
<translation>Zoeken</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>New Toot</source>
<translation>Nieuw</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>@user or #term</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
@ -147,6 +151,14 @@
<source>Settings</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Loading</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Performing request, please wait or request something else</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Profile</name>

View file

@ -103,23 +103,27 @@
<name>MainPage</name>
<message>
<source>Home</source>
<translation>Acuèlh</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Timeline</source>
<translation>Flux</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Notifications</source>
<translation>Notificacions</translation>
</message>
<message>
<source>Search</source>
<translation>Cercar</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>New Toot</source>
<translation>Nòu tut</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>@user or #term</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
@ -147,6 +151,14 @@
<source>Settings</source>
<translation>Parmètres</translation>
</message>
<message>
<source>Loading</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Performing request, please wait or request something else</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Profile</name>

View file

@ -103,23 +103,27 @@
<name>MainPage</name>
<message>
<source>Home</source>
<translation>Почетна</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Timeline</source>
<translation>Временска линија</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Notifications</source>
<translation>Обавјештење</translation>
</message>
<message>
<source>Search</source>
<translation>Претрага</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>New Toot</source>
<translation>Нова</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>@user or #term</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
@ -147,6 +151,14 @@
<source>Settings</source>
<translation>Подешавања</translation>
</message>
<message>
<source>Loading</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Performing request, please wait or request something else</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Profile</name>

View file

@ -103,23 +103,27 @@
<name>MainPage</name>
<message>
<source>Home</source>
<translation>Home</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Timeline</source>
<translation>Timeline</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Notifications</source>
<translation>Notifications</translation>
</message>
<message>
<source>Search</source>
<translation>Search</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>New Toot</source>
<translation>New</translation>
<translation type="unfinished"></translation>
</message>
<message>
<source>Search</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>@user or #term</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
@ -147,6 +151,14 @@
<source>Settings</source>
<translation>Settings</translation>
</message>
<message>
<source>Loading</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Performing request, please wait or request something else</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Profile</name>