bugfixes reply in Friendica 3/2022 and image download

This commit is contained in:
LubuWest 2022-03-13 21:22:08 +01:00
parent 4ffae4ac31
commit 48a904b8c0
15 changed files with 909 additions and 855 deletions

View File

@ -1,3 +1,8 @@
## v0.6.5
* Fix reply in Friendica 3/2022 version due to API bug
* Image downloads work again
* Some additional emojis
## v0.6.4
@ -5,7 +10,6 @@
* Filter contacts
* many new emojis
* Replaced Favorite button with Reply button due to buggy Favourite API
* View newsitem on website (works only in coversation view)
* Rebuild contacts handling due to buggy Contacts API
* Removed permissions for new messages due to buggy Contacts API
* Sync all accounts in background (not only active)

View File

@ -1,5 +1,5 @@
<?xml version="1.0"?>
<manifest package="org.qtproject.friendiqa" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.6.4" android:versionCode="30" android:installLocation="auto">
<manifest package="org.qtproject.friendiqa" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.6.5" android:versionCode="31" android:installLocation="auto">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30"/>
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.

View File

@ -224,7 +224,7 @@ void XHR::getlist()
XHR::setUrl(m_filelist.at(dlindex));}
else {
XHR::setUrl(m_filelist.at(dlindex));}
//qDebug() << "start download" << m_url;
qDebug() << "start download" << m_url;
XHR::download();
} else {dlindex=0;m_downloadtype="";m_contactlist.clear();m_filelist.clear();}
}
@ -293,6 +293,7 @@ void XHR::onReplySuccess()
void XHR::onRequestFinished()
{
// Save the file here
//qDebug() << "buffer " << buffer;
if (buffer.isNull()){qDebug() << "File empty"<<m_url; buffer.clear(); emit this->error(m_downloadtype,m_url,m_api,1);}
else if (m_downloadtype=="picturelist") {
QJsonDocument jsonResponse = QJsonDocument::fromJson(buffer);

View File

@ -59,7 +59,7 @@ function friendicaPostRequest(login,api,data,method,rootwindow,callback) {
//print(api+JSON.stringify(login)+Qt.atob(login.password));
if (xhrequest.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
} else if(xhrequest.readyState === XMLHttpRequest.DONE) {
try{ if (xhrequest.responseText!=""){
try{ if (xhrequest.responseText!=""){print (xhrequest.responseText)
callback(xhrequest.responseText)
}else{//print("API:\n" +api+" NO RESPONSE");
//showMessage("Error","API:\n" +api+" NO RESPONSE",rootwindow)

View File

@ -54,7 +54,8 @@ function dataRequest(login,photo,database,xhr,rootwindow) {
// check if image exist and call download function
Helperjs.friendicaRequest(login,"/api/friendica/photo?photo_id="+photo.id, rootwindow, function (image){
if(image==""){currentimageno=currentimageno+1}else{
if(image=="" || typeof(image)=="undefined"){currentimageno=currentimageno+1}else{
try{
var obj = JSON.parse(image);
if (obj.hasOwnProperty('status')){
@ -109,6 +110,30 @@ function dataRequest(login,photo,database,xhr,rootwindow) {
}
})
}} catch (e){
var helpfilename=photo.filename.substring(0,photo.filename.lastIndexOf("."));
var filesuffix="";
if (photo.type=="image/jpeg"){filesuffix=".jpg"}
else if (photo.type=="image/png"){filesuffix=".png"}
else {filesuffix=""}
if (helpfilename==""){// check if file has any filename
photo.filename=photo["id"]+filesuffix;
}
else{photo.filename=helpfilename+filesuffix}
var link="";
xhr.setUrl(Qt.resolvedUrl(photo.thumb));
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setFilename(login.imagestore+'albums/'+photo.album+"/"+photo["filename"]);
xhr.setDownloadtype("picture");
xhr.download();
var db=Sql.LocalStorage.openDatabaseSync(database[0],database[1],database[2],database[3]);
db.transaction( function(tx) {
var result = tx.executeSql('SELECT * from imageData where id = "'+photo["id"]+'"');
if(result.rows.length === 1) {// use update
result = tx.executeSql('UPDATE imageData SET username ="' +login.username+ '",id="'+photo.id+'", created="'+photo.created+'", edited="'+photo.edited+'", profile="0", link="'+photo["thumb"]+'", filename="'+photo.filename+'",title="", desc="'+photo.desc+'", type="'+photo.type+'", width="0", height="0", album="'+photo.album+'", location="file://'+login.imagestore+'albums/'+photo.album+'/" where id="'+photo["id"]+'"');
} else {// use insert print('... does not exists, create it')
result = tx.executeSql('INSERT INTO imageData VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)', [login.username,photo.id,photo.created,photo.edited,'', photo.desc, photo.album, photo.filename, photo.type, '', '',0,photo["thumb"],'file://'+login.imagestore+'albums/'+photo.album+"/"]);
}
})
print("Data retrieval failure! "+ e+obj);
}
}})

View File

@ -344,19 +344,19 @@ function deleteNews(login,database,newsid,messagetype,rootwindow,callback){
})}
function retweetNews(login,database,newsid,rootwindow,callback){
Helperjs.friendicaPostRequest(login,"/api/statuses/retweet?id="+newsid,"","POST", rootwindow,function (obj){
Helperjs.friendicaPostRequest(login,"/api/v1/statuses/"+newsid+"/reblog","","POST", rootwindow,function (obj){
var answer=JSON.parse(obj);
if(answer.hasOwnProperty('status'))//('error' in answer.status)
{Helperjs.showMessage("Repost",answer.status.code,rootwindow);}
else{Helperjs.showMessage("Repost",answer.text,rootwindow)}
else{Helperjs.showMessage("Repost",answer.content,rootwindow)}
})
}
function favorite(login,favorited,newsid,rootwindow){
// toggle favorites
if(favorited){ Helperjs.friendicaPostRequest(login,"/api/favorites/create?id="+newsid,"","POST", rootwindow,function (obj){
if(favorited){ Helperjs.friendicaPostRequest(login,"/api/v1/statuses/"+newsid+"/bookmark","","POST", rootwindow,function (obj){
})}
else {Helperjs.friendicaPostRequest(login,"/api/favorites/destroy?id="+newsid,"","POST",rootwindow,function (obj){
else {Helperjs.friendicaPostRequest(login,"/api/v1/statuses/"+newsid+"/unbookmark","","POST",rootwindow,function (obj){
})}
}

View File

@ -455,7 +455,7 @@ function processNews(api,data){
usermessages.push(newslist.status);
newslist=usermessages;
}
if (data==""){newsBusy.running=false}
if (data=="" || api=="/api/v1/statuses"){print("data "+data); newsBusy.running=false}
else if (typeof(newslist)=='undefined'){
Helperjs.showMessage(qsTr("Undefined Array Error"),"API:\n" +login.server+api+"\n Return: \n"+data,root)
}

View File

@ -82,6 +82,12 @@ var html=[//Smileys
'\ud83d\ude4E',
'\ud83d\ude4F',
'\ud83e\udd2F',
'\uD83D\uDC4D',
'\u2764\uFE0F',
'\uD83D\uDCA9',
'\uD83D\uDC2D',
'\uD83D\uDC2E',
'\uD83D\uDC31',
'\u2639',
'\u263B',
//Weather

View File

@ -43,7 +43,7 @@ Page{
font.pointSize: osSettings.systemFontSize
color:Material.primaryTextColor
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
text: "<b>Friendiqa v0.6.4 </b><br>Licensed under GPL 3 with the exception of OpenSSL <br> "+
text: "<b>Friendiqa v0.6.5 </b><br>Licensed under GPL 3 with the exception of OpenSSL <br> "+
"Website <a href='https://friendiqa.ma-nic.de'>https://friendiqa.ma-nic.de</a><br>"+
"Sourcecode: <a href='https://git.friendi.ca/LubuWest/Friendiqa'>https://git.friendi.ca/LubuWest/Friendiqa</a><br>"+
"Privacy Policy: <a href='https://git.friendi.ca/lubuwest/Friendiqa/src/branch/master/PrivacyPolicy.md'>http://git.friendi.ca/lubuwest/Friendiqa/src/branch/master/PrivacyPolicy.md</a><br>"+

View File

@ -95,7 +95,7 @@ Page {
//x:3*mm
//y:8*mm
width: conversationList.width//-4*mm
height:conversationList.height//-20*mm
height:conversationList.height-root.fontFactor*osSettings.bigFontSize//-20*mm
clip: true
spacing: 0
footer: MessageSend{conversation:true}

View File

@ -89,9 +89,10 @@ Rectangle{
function statusUpdate(title,status,in_reply_to_status_id,attachImageURL) {
//xhr.url= login.server + "/api/statuses/update.json";
try{newsBusy.running=true;}catch(e){conversationBusy.running=true}
try{newsBusy.running=true;conversationBusy.running=true}catch(e){}
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setUrl(login.server);
if (in_reply_to_status_id==""){
xhr.setApi("/api/statuses/update");
xhr.clearParams();
xhr.setParam("source", "Friendiqa");
@ -107,9 +108,18 @@ Rectangle{
xhr.setImageFileParam("media", attachImageURL[image]);
xhr.setImageFileParam("angle", rotator.angle.toString());
}
};
}
xhr.post();
Newsjs.storeHashtags(login,db,status,root)
}else {
xhr.setApi("/api/v1/statuses");
xhr.clearParams();
xhr.setParam("status", status);
xhr.setParam("in_reply_to_id", in_reply_to_status_id);
xhr.post();
Newsjs.storeHashtags(login,db,status,root)
messageSend.destroy()
}
}
function dmUpdate(title,text,replyto,screen_name,attachImageURL) {
@ -379,6 +389,7 @@ Rectangle{
spacing: mm
height: 2.5*root.fontFactor*osSettings.bigFontSize//12*mm
x: 0.5*mm
// MButton{id:permButton //Permissions not working in Friendica 02/2022
// visible: !conversation && (newsSwipeview.stacktype!=="DirectMessages")
// height: 2*root.fontFactor*osSettings.bigFontSize
@ -450,7 +461,10 @@ Rectangle{
var body=bodyField.getFormattedText(0,bodyField.length);
var dmbody=bodyField.getText(0,bodyField.length);
if (conversation || newsSwipeview.stacktype!=="DirectMessages"){
statusUpdate(title,body,parentId,attachImageURLs)
if (parentId!=""){
statusUpdate(title,dmbody,parentId,attachImageURLs)
}else{
statusUpdate(title,body,parentId,attachImageURLs)}
}else {
if (reply_to_user!=""){dmUpdate(title,dmbody,parentId,reply_to_user)}
else{Helperjs.showMessage(qsTr("Error"),qsTr("No receiver supplied!"),root)}
@ -512,6 +526,9 @@ Rectangle{
PropertyChanges {
target: titleField; visible:false
}
PropertyChanges {
target: attachButton; visible:false
}
PropertyChanges {
target: bodyField; placeholderText:"";focus:true
}

View File

@ -48,7 +48,7 @@ Rectangle{
MouseArea {anchors.fill:parent;
onClicked:{
rootstackView.push("qrc:/qml/newsqml/NewsVideoLarge.qml",{"source": attachment.url,"mimetype": attachment.mimetype});
rootstackView.push("qrc:/qml/newsqml/NewsVideoLarge.qml",{"source": Qt.resolvedUrl(attachment.url),"mimetype": attachment.mimetype});
}
}
}

View File

@ -29,8 +29,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
import QtMultimedia 5.8
import QtQuick 2.9
import QtMultimedia 5.15
import QtQuick 2.11
import QtQuick.Controls 2.12
import "qrc:/qml/genericqml"

View File

@ -129,7 +129,8 @@ Item {
font.pointSize: 0.6*osSettings.systemFontSize
font.family: "Noto Sans"
horizontalAlignment: Label.AlignRight
text: (newsitemobject.in_reply_to_status_id!="null"&&newsitemobject.in_reply_to_status_id!=null)?" \u00B7 "+qsTr("In reply to ")+newsitemobject.reply_user.screen_name:" "
//text: (newsitemobject.in_reply_to_status_id!="null"&&newsitemobject.in_reply_to_status_id!=null)?" \u00B7 "+qsTr("In reply to ")+newsitemobject.reply_user.screen_name:" "
text: (newsitemobject.reply_user!=false&&typeof(newsitemobject.reply_user)!="undefined")?" \u00B7 "+qsTr("In reply to ")+newsitemobject.reply_user.screen_name:" "
}
}
}
@ -330,31 +331,31 @@ Item {
}}
}
// CheckBox {
// id:favoritedCheckbox
// visible:((newsitemobject.messagetype==0)||(newsitemobject.messagetype==3))
// width: newsitem.width/5
// height: parent.height
// indicator:Rectangle{
// implicitWidth: newsitem.width/5
// implicitHeight:root.fontFactor*osSettings.bigFontSize
// color:"transparent"
// Text{
// anchors.centerIn: parent
// font.pointSize: osSettings.systemFontSize
// font.family:fontAwesome.name
// color: favoritedCheckbox.checked?Material.primaryTextColor: Material.secondaryTextColor
// text:"\uf005"
// }
// }
// checked:(newsitemobject.favorited>0)
// onClicked:{
// if(favoritedCheckbox.checkState==Qt.Checked){
// Newsjs.favorite(login,true,newsitemobject.id,root); model.newsitemobject.favorited=1}
// else if(favoritedCheckbox.checkState==Qt.Unchecked){
// Newsjs.favorite(login,false,newsitemobject.id,root);model.newsitemobject.favorited=0}
// }
// }
CheckBox {
id:favoritedCheckbox
visible:((newsitemobject.messagetype==0)||(newsitemobject.messagetype==3))
width: newsitem.width/5
height: parent.height
indicator:Rectangle{
implicitWidth: newsitem.width/5
implicitHeight:root.fontFactor*osSettings.bigFontSize
color:"transparent"
Text{
anchors.centerIn: parent
font.pointSize: osSettings.systemFontSize
font.family:fontAwesome.name
color: favoritedCheckbox.checked?Material.primaryTextColor: Material.secondaryTextColor
text:"\uf005"
}
}
checked:(newsitemobject.favorited>0)
onClicked:{
if(favoritedCheckbox.checkState==Qt.Checked){
Newsjs.favorite(login,true,newsitemobject.id,root); model.newsitemobject.favorited=1}
else if(favoritedCheckbox.checkState==Qt.Unchecked){
Newsjs.favorite(login,false,newsitemobject.id,root);model.newsitemobject.favorited=0}
}
}
Rectangle{
width: newsitem.width/5
height: parent.height

View File

@ -58,16 +58,16 @@ StackView{
if(albums.indexOf(fotorectangle.newimages[i].album)==-1){
filesystem.Directory=root.login.imagestore+"/albums";
filesystem.makeDir(fotorectangle.newimages[i].album)}
//ownimagelist.push(root.login.server+"/api/friendica/photo?scale='0'&photo_id="+fotorectangle.newimages[i].id);
ownimagelist.push(root.login.server+"/api/friendica/photo?photo_id="+fotorectangle.newimages[i].id);
}
Imagejs.dataRequest(login,fotorectangle.newimages[0],db,xhr,fotorectangle);
//Imagejs.dataRequest(login,fotorectangle.newimages[0],db,xhr,fotorectangle);
})
// xhr.setLogin(login.username+":"+Qt.atob(login.password));
// xhr.setImagedir(login.imagestore);
// xhr.setFilelist(ownimagelist);
// xhr.setDownloadtype("picturelist");
// xhr.getlist();
xhr.setLogin(login.username+":"+Qt.atob(login.password));
xhr.setImagedir(login.imagestore);
print("ownimagelist "+JSON.stringify(ownimagelist))
xhr.setFilelist(ownimagelist);
xhr.setDownloadtype("picturelist");
xhr.getlist();
newImagesProgress.visible=true
}
}
@ -78,7 +78,7 @@ StackView{
fotorectangle.newimages=[];fotorectangle.currentimageno=0
}else{
// download next image
Imagejs.dataRequest(login,fotorectangle.newimages[currentimageno],db,xhr,fotorectangle)
//Imagejs.dataRequest(login,fotorectangle.newimages[currentimageno],db,xhr,fotorectangle)
}
}
@ -95,8 +95,8 @@ StackView{
}
function onError(data,url,api,code){
if(data=="picturelist"){
var requestid=url.substring(url.lastIndexOf("=")+1);
Imagejs.dataRequest(login,requestid,db,xhr,fotorectangle);
// var requestid=api.substring(api.lastIndexOf("=")+1);
// Imagejs.dataRequest(login,requestid,db,xhr,fotorectangle);
fotorectangle.currentimageno=fotorectangle.currentimageno+1
} else if (data=="picture"){
Helperjs.deleteData(root.db,"imageData",root.login.username,function(){