Friendiqa v0.2.2

This commit is contained in:
LubuWest 2018-04-22 21:12:40 +02:00
parent d52c76792b
commit 65d9696609
22 changed files with 345 additions and 91 deletions

View file

@ -58,3 +58,9 @@
* Fix for Friendica [issue 4689](https://github.com/friendica/friendica/issues/4689)
* Long posts are automatically truncated
* Intents for pictures (Send one image from gallery: attach to message, send multiple images: upload to album)
## v0.2.2 ##
* Fix for [issue 5](https://github.com/LubuWest/Friendiqa/issues/5)
* Link to list of public server on Config Tab
* Small redesign of SendMessage page
* Intents for texts/urls (Send text or url from everywhere to create message)

BIN
Friendiqa_v0.2.2.apk Normal file

Binary file not shown.

View file

@ -30,6 +30,7 @@ Currently supported:
* More shows older posts from local DB
* Create new Message with images or direct messages, Contact/Group access rights(can be stored), smileys
* Send image from Android gallery
* Send text or urls from other apps to Friendiqa
* Native Android image dialog
ToDo:

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.2.1" android:versionCode="5" android:installLocation="auto">
<manifest package="org.qtproject.friendiqa" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.2.2" android:versionCode="6" android:installLocation="auto">
<application android:hardwareAccelerated="true" android:vmSafeMode="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="Friendiqa" android:icon="@drawable/friendiqa" android:logo="@drawable/friendiqa" android:theme="@android:style/Theme.Holo.Light">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="androidnative.friendiqa.FriendiqaActivity" android:label="Friendiqa" android:screenOrientation="unspecified" android:launchMode="singleInstance" android:taskAffinity="">
<intent-filter>
@ -12,6 +12,11 @@
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="image/*"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/*"/>
</intent-filter>
<meta-data android:name="android.app.lib_name" android:value="friendiqa"/>
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
<meta-data android:name="android.app.repository" android:value="default"/>

View file

@ -21,14 +21,23 @@ public class AndroidNativeActivity extends org.qtproject.qt5.android.bindings.Qt
protected void onResume() {
super.onResume();
if((getIntent().getFlags() == (Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY)) || (getIntent().getFlags() == Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) || (getIntent().getFlags() == Intent.FLAG_ACTIVITY_NEW_TASK) || (getIntent().getFlags() == Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED)) {
if((getIntent().getFlags() == (Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY)) || (getIntent().getFlags() == Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) || (getIntent().getFlags() == Intent.FLAG_ACTIVITY_NEW_TASK) || (getIntent().getFlags() == Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED) || (getIntent().getFlags() == (Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED))) {
SystemDispatcher.onActivityResume();
} else {
Intent data = getIntent();
if ((data != null) && !(data.getBooleanExtra("used",false))){
SystemDispatcher.loadClass("androidnative.ImagePicker");
SystemDispatcher.onActivityResult(0x245285a3,Activity.RESULT_OK,data);
if ((data!=null) && (data.getType() != null) && !(data.getBooleanExtra("used",false))){
String type = data.getType();
String[] parts = type.split("/");
String maintype= parts[0];
if (maintype.equals("text")){
SystemDispatcher.loadClass("androidnative.TextIntent");
SystemDispatcher.onActivityResult(0x245285a4,Activity.RESULT_OK,data);
} else {
SystemDispatcher.loadClass("androidnative.ImagePicker");
SystemDispatcher.onActivityResult(0x245285a3,Activity.RESULT_OK,data);
}
getIntent().replaceExtras(new Bundle());
getIntent().setAction("");
getIntent().setData(null);
@ -42,13 +51,25 @@ public class AndroidNativeActivity extends org.qtproject.qt5.android.bindings.Qt
protected void onNewIntent(Intent data) {
super.onNewIntent(data);
SystemDispatcher.loadClass("androidnative.ImagePicker");
SystemDispatcher.onActivityResult(0x245285a3,Activity.RESULT_OK,data);
getIntent().replaceExtras(new Bundle());
getIntent().setAction("");
getIntent().setData(null);
getIntent().setFlags(0);
getIntent().putExtra("used", true);
if ((data!=null) && (data.getType() != null) && !(data.getBooleanExtra("used",false))){
String type = data.getType();
String[] parts = type.split("/");
String maintype= parts[0];
if (maintype.equals("text")){
SystemDispatcher.loadClass("androidnative.TextIntent");
SystemDispatcher.onActivityResult(0x245285a4,Activity.RESULT_OK,data);
} else {
SystemDispatcher.loadClass("androidnative.ImagePicker");
SystemDispatcher.onActivityResult(0x245285a3,Activity.RESULT_OK,data);
}
getIntent().replaceExtras(new Bundle());
getIntent().setAction("");
getIntent().setData(null);
getIntent().setFlags(0);
getIntent().putExtra("used", true);
} else {
SystemDispatcher.onActivityResume();
}
} // onNewIntent
}

View file

@ -17,8 +17,6 @@ import android.util.Log;
import android.os.Handler;
import android.os.Looper;
import android.content.Intent;
//import android.content.*;
//import android.app.*;
import android.os.*;
import java.util.concurrent.Semaphore;
import java.io.StringWriter;
@ -133,19 +131,21 @@ public class SystemDispatcher {
*/
public static void onActivityResult (int requestCode, int resultCode, Intent data) {
Map message = new HashMap();
message.put("requestCode",requestCode);
message.put("resultCode",resultCode);
message.put("data",data);
if(isInitialized) {
dispatch(ACTIVITY_RESULT_MESSAGE,message);
waitingIntent=null;
isIntentPending=false;
} else { //onIntent start
message.put("text",data.getStringExtra(Intent.EXTRA_TEXT));
message.put("subject",data.getStringExtra(Intent.EXTRA_SUBJECT));
waitingIntent = message;
isIntentPending = true;
}
//onIntent end
@ -216,7 +216,6 @@ public class SystemDispatcher {
try {
ClassLoader classLoader = SystemDispatcher.class.getClassLoader();
Class aClass = Class.forName(className,true,classLoader);
// Log.d(TAG,"Class Loaded: " + className);
} catch (ClassNotFoundException e) {
Log.e(TAG,"Failed to load class: " + className);
e.printStackTrace();

View file

@ -0,0 +1,59 @@
package androidnative;
import org.qtproject.qt5.android.QtNative;
import android.content.Intent;
import android.app.Activity;
import java.util.Map;
import java.util.HashMap;
import android.os.Environment;
import android.util.Log;
public class TextIntent {
// Random
public static final int TEXT_INTENT_ACTION = 0x245285a4;
public static final String CHOSEN_MESSAGE = "androidnative.TextIntent.chosen";
private static final String TAG = "androidnative.TextIntent";
private static Boolean broadcast = false;
static {
SystemDispatcher.addListener(new SystemDispatcher.Listener() {
public void onDispatched(String type , Map message) {
if (type.equals(SystemDispatcher.ACTIVITY_RESULT_MESSAGE)) {
onActivityResult(message);
}
}
});
}
static private void onActivityResult(Map message) {
int resultCode = (Integer) message.get("resultCode");
if (resultCode != Activity.RESULT_OK)
return;
int requestCode = (Integer) message.get("requestCode");
Intent data = (Intent) message.get("data");
if (requestCode == TEXT_INTENT_ACTION) {
String extrasubject = (String) message.get("subject");
String extratext = (String) message.get("text");
importText(data,extrasubject,extratext);
}
}
static private void importText(Intent data, String extrasubject, String extratext) {
String subject = data.getStringExtra(Intent.EXTRA_SUBJECT);
String plaintext = data.getStringExtra(Intent.EXTRA_TEXT);
String htmltext = data.getStringExtra(Intent.EXTRA_HTML_TEXT);
if (subject==null){subject=extrasubject;};
if (plaintext==null){plaintext=extratext;};
Map reply = new HashMap();
reply.put("subject",subject);
reply.put("plaintext",plaintext);
reply.put("htmltext",htmltext);
SystemDispatcher.dispatch(CHOSEN_MESSAGE,reply);
}
}

View file

@ -218,5 +218,6 @@
<file>qml/contactqml/ProfileComponent.qml</file>
<file>translations/friendiqa-it.ts</file>
<file>translations/friendiqa-it.qm</file>
<file>qml/genericqml/IntentReceiver.qml</file>
</qresource>
</RCC>

View file

@ -59,8 +59,9 @@ StackView{
function setServericon(server){
try {Helperjs.friendicaWebRequest(server+"/api/statusnet/config",configBackground, function (obj){
var serverdata = JSON.parse(obj);
servericon.source=serverdata.site.logo})} catch(e){print(e)}
var serverdata = JSON.parse(obj);
servericon.visible=true;
servericon.source=serverdata.site.logo})} catch(e){print(e)}
}
BlueButton{
@ -127,6 +128,7 @@ StackView{
id:servericon
x:19*mm;y:10*mm
width:5*mm; height: 5*mm
visible: false
source:""
MouseArea{
anchors.fill:parent
@ -137,6 +139,17 @@ StackView{
}
}
BlueButton{
id:serverSearchButton
text:"\uf002"
x:19*mm
y:10*mm
width: 5*mm; height:5*mm
visible: servericon.visible?false:true
onClicked:{Qt.openUrlExternally(Qt.resolvedUrl("https://dir.friendica.social/servers"))}
}
Rectangle{color: "light grey"; x: 25*mm; y: 10*mm; width: root.width/2; height: 5*mm;}
Flickable {
id: servernameFlickable
@ -327,6 +340,7 @@ StackView{
filesystem.rmDir();
configBackground.registeredUser=true;
servername.text="https://...";
servericon.visible=false;
servericon.source="";
username.text="";
password.text="";
@ -349,6 +363,7 @@ StackView{
onClicked:{
configBackground.registeredUser=true;
servername.text="https://..."
servericon.visible=false;
servericon.source="";
username.text=""
password.text=""

View file

@ -36,11 +36,13 @@ import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.4
import "qrc:/js/news.js" as Newsjs
import "qrc:/js/service.js" as Service
import "qrc:/qml/genericqml"
TabView{
id:root
property QtObject osSettings: {var tmp=Qt.createComponent("qrc:/qml/configqml/OSSettingsAndroid.qml");return tmp.createObject(root)}
IntentReceiver{}
tabPosition: Qt.BottomEdge
width: osSettings.appWidth
height:osSettings.appHeight
@ -58,6 +60,7 @@ TabView{
signal contactdetailsSignal(var contact)
signal eventSignal(var contact)
signal uploadSignal(var urls)
signal sendtextSignal(var intenttext)
property var news:[]
property var newContacts:[]
@ -189,11 +192,11 @@ TabView{
id: configtab
source: (root.currentIndex==4)?"qrc:/qml/configqml/ConfigTab.qml":""
}
Component.onCompleted: {
var imagePicker = Qt.createQmlObject('import QtQuick 2.0; import "qrc:/qml/genericqml";'+
osSettings.imagePickQml+'{multiple : true; onReady: {'+
'if(imageUrls.length==1){root.currentIndex=0;newstab.active=true;root.uploadSignal(imageUrls)} else{'+
' root.currentIndex=2;fotostab.active=true;'+
'root.uploadSignal(imageUrls)};}}',root,"imagePicker");
}
// Component.onCompleted: {
// var imagePicker = Qt.createQmlObject('import QtQuick 2.0; import "qrc:/qml/genericqml";'+
// osSettings.imagePickQml+'{multiple : true; onReady: {'+
// 'if(imageUrls.length==1){root.currentIndex=0;newstab.active=true;root.uploadSignal(imageUrls)} else{'+
// ' root.currentIndex=2;fotostab.active=true;'+
// 'root.uploadSignal(imageUrls)};}}',root,"imagePicker");
// }
}

View file

@ -0,0 +1,43 @@
import QtQuick 2.0
import AndroidNative 1.0
Item {
/// The URL of the image chosen. If multiple images are picked, it will be equal to the first image.
property string imageUrl: ""
/// A list of images chosen
property var imageUrls: []
property string m_TEXT_MESSAGE: "androidnative.TextIntent.chosen";
property string m_IMAGE_MESSAGE: "androidnative.ImagePicker.chosen";
Connections {
target: SystemDispatcher
onDispatched: {
if (type === m_IMAGE_MESSAGE) {
var h=[];
for (var n in message.imageUrls){
h.push("file://"+ decodeURIComponent(message.imageUrls[n]).substring(5))
}
imageUrls=h;
if(imageUrls.length==1){
root.currentIndex=0;newstab.active=true;
root.uploadSignal(imageUrls)
} else{
root.currentIndex=2;fotostab.active=true;
root.uploadSignal(imageUrls)
}
} else if (type==m_TEXT_MESSAGE){
root.currentIndex=0;newstab.active=true;
root.sendtextSignal(message)
}
}
}
Component.onCompleted: {
SystemDispatcher.setInitialized();
}
}

View file

@ -196,7 +196,7 @@ Rectangle{
anchors.bottomMargin:1
text:"\u2713"
onClicked:{updatePerms();
permissionDialog.destroy();
permissionDialog.visible=false;
}
}

View file

@ -47,6 +47,7 @@ Flickable{
id:messageSend
property string parentId: ""
property string reply_to_user:""
property alias bodyMessage: bodyField.text
property var attachImageURLs: [];
property int directmessage: 0;
property var contacts: []
@ -58,7 +59,8 @@ Flickable{
function attachImage(url){
var imageAttachmentObject=Qt.createQmlObject('import QtQuick 2.0; Image {id:imageAttachment'+attachImageURLs.length+'; source:"'+
url.toString()+'"; width: 15*mm; height: 15*mm;fillMode: Image.PreserveAspectFit;MouseArea{anchors.fill:parent;onClicked:{attachImageURLs.splice(attachImageURLs.indexOf("'+url+'"),1); imageAttachment'+attachImageURLs.length+'.destroy()}}}',messageColumn,"attachedImage");
url.toString()+'"; x:2*mm; width: 45*mm; height: 45*mm;fillMode: Image.PreserveAspectFit;MouseArea{anchors.fill:parent;onClicked:{attachImageURLs.splice(attachImageURLs.indexOf("'+
url+'"),1); imageAttachment'+attachImageURLs.length+'.destroy()}}}',messageColumn,"attachedImage");
}
function statusUpdate(title,status,in_reply_to_status_id,attachImageURL) {
@ -90,7 +92,7 @@ Flickable{
Column {
id:messageColumn
spacing: 2
spacing: 0.5*mm
width: parent.width
TextField {
id: titleField
@ -99,14 +101,23 @@ Flickable{
visible: messageSend.parentId === ""
}
TextArea {
id: bodyField
width: parent.width
height: 30*mm
wrapMode: TextEdit.Wrap
textFormat: TextEdit.PlainText
Rectangle{
color: "white"
radius: 0.5*mm
x:mm
width: parent.width-2*mm
height:Math.max(bodyField.contentHeight+2*mm,10*mm)
TextArea {
id: bodyField
anchors.fill: parent
font.pixelSize: 3*mm
wrapMode: Text.Wrap
selectByMouse: true
textFormat: TextEdit.PlainText
}
}
Row{
spacing: 2
CheckBox{
@ -143,10 +154,9 @@ Flickable{
text:"\u2713"
onClicked: {if(urlTextEdit.text!=""){
var start = bodyField.selectionStart;
var end = bodyField.selectionEnd;
var text = bodyField.getText(start,end);
var text=bodyField.selectedText
text = "[url="+urlTextEdit.text+"]" + text + "[/url]";
bodyField.remove(start,end);
bodyField.remove(start,bodyField.selectionEnd);
bodyField.insert(start,text);}
urlRectangle.visible=false}
}
@ -158,13 +168,11 @@ Flickable{
BlueButton{id:permButton
visible: (directmessage==1)?false:true
text: ((contact_allow.length==0)&&(contact_deny.length==0)&&(group_allow.length==0)&&(group_deny.length==0))?"\uf09c":"\uf023"
onClicked: {
var component = Qt.createComponent("qrc:/qml/genericqml/PermissionDialog.qml");
var permissions = component.createObject(messageColumn);
}}
onClicked: { permissionDialog.visible=true;}
}
BlueButton {
id: attachButton
text: "\uf0c6"
text: "\uf03e"
visible:(directmessage==0)
onClicked: {
if (attachImageURLs.length>0){//Server currently accepts only one attachment
@ -189,27 +197,26 @@ Flickable{
if(Helperjs.getCount(db,login,"contacts","screen_name",contacts[i].screen_name)>1){
contacts[i].screen_name=contacts[i].screen_name+"+"+contacts[i].cid
}
contactitems=contactitems+"MenuItem{text:'"+contacts[i].screen_name+"';iconSource:'"+contacts[i].profile_image+"'; onTriggered: bodyField.insert(0,' @"+contacts[i].screen_name+" ')}"
contactitems=contactitems+"MenuItem{text:'"+contacts[i].screen_name+"'; onTriggered: bodyField.insert(0,' @"+contacts[i].screen_name+" ')}"
}}
var menuString="import QtQuick.Controls 1.4; Menu {"+contactitems+"}";
var contactlistObject=Qt.createQmlObject(menuString,messageSend,"contactmenuOutput")
var contactlistObject=Qt.createQmlObject(menuString,messageColumn,"contactmenuOutput")
contactlistObject.popup() }
}
BlueButton{
id:smileyButton
text: "\uf118"
onClicked: {
var smileyarray=Smileyjs.smileys
var component = Qt.createComponent("qrc:/qml/newsqml/SmileyDialog.qml");
var smileydialog = component.createObject(messageColumn)
}}
onClicked: {smileyDialog.visible=true}
}
BlueButton {
id: cancelButton
text: "\uf057"
onClicked: {newstab.newstabstatus=login.newsViewType;
newsStack.pop(null)}
onClicked: {
newstab.newstabstatus=login.newsViewType;
newsStack.pop(null)
}
}
BlueButton {
id: sendButton
@ -224,7 +231,8 @@ Flickable{
}
}
}
PermissionDialog{id:permissionDialog;x:mm;visible: false}
SmileyDialog{id:smileyDialog;x:mm;visible: false}
}
Component.onCompleted: if(attachImageURLs.length>0){attachImage(attachImageURLs[0])}
}

View file

@ -117,7 +117,14 @@ Item {
function sendUrls(urls){
if((urls.length==1)&&(newsStack.depth<2)){
newsStack.push([newslistRectangle,{item:"qrc:/qml/newsqml/MessageSend.qml",properties:{attachImageURLs:urls}}])
newsStack.push([newslistRectangle,{item:"qrc:/qml/newsqml/MessageSend.qml",properties:{attachImageURLs:urls}}])
}
}
function sendtext(text){
if(text&&(newsStack.depth<2)){
if (text.subject=="undefined"){text.subject=""}
newsStack.push([newslistRectangle,{item:"qrc:/qml/newsqml/MessageSend.qml",properties:{bodyMessage:text.subject+"\n"+text.plaintext}}])
}
}
@ -338,6 +345,7 @@ Item {
root.directmessageSignal.connect(onDirectMessage);
root.newsSignal.connect(showNews);
root.uploadSignal.connect(sendUrls);
root.sendtextSignal.connect(sendtext);
try{newsModel.clear()} catch(e){}
//print("imageUrls "+JSON.stringify(imageUrls)+" newsstack.depth:"+newsStack.depth);

View file

@ -49,7 +49,7 @@ Rectangle{
anchors.right: parent.right
anchors.rightMargin: 1*mm
text: "\uf057"
onClicked:{smileyDialog.destroy()}
onClicked:{smileyDialog.visible=false}
}
TabView{
@ -164,7 +164,8 @@ Rectangle{
MouseArea{
anchors.fill: parent
onClicked:{
bodyField.append(emoji.name+" ")
//bodyField.append(emoji.name+" ")
bodyField.insert(bodyField.cursorPosition,emoji.name+" ");
smileyDialog.destroy()
}
}

View file

@ -59,8 +59,9 @@ StackView{
function setServericon(server){
try {Helperjs.friendicaWebRequest(server+"/api/statusnet/config",configBackground, function (obj){
var serverdata = JSON.parse(obj);
servericon.source=serverdata.site.logo})} catch(e){print(e)}
var serverdata = JSON.parse(obj);
servericon.visible=true;
servericon.source=serverdata.site.logo})} catch(e){print(e)}
}
BlueButton{
@ -127,6 +128,7 @@ StackView{
id:servericon
x:19*mm;y:10*mm
width:5*mm; height: 5*mm
visible: false
source:""
MouseArea{
anchors.fill:parent
@ -137,6 +139,17 @@ StackView{
}
}
BlueButton{
id:serverSearchButton
text:"\uf002"
x:19*mm
y:10*mm
width: 5*mm; height:5*mm
visible: servericon.visible?false:true
onClicked:{Qt.openUrlExternally(Qt.resolvedUrl("https://dir.friendica.social/servers"))}
}
Rectangle{color: "light grey"; x: 25*mm; y: 10*mm; width: root.width/2; height: 5*mm;}
Flickable {
id: servernameFlickable
@ -327,6 +340,7 @@ StackView{
filesystem.rmDir();
configBackground.registeredUser=true;
servername.text="https://...";
servericon.visible=false;
servericon.source="";
username.text="";
password.text="";
@ -349,6 +363,7 @@ StackView{
onClicked:{
configBackground.registeredUser=true;
servername.text="https://..."
servericon.visible=false;
servericon.source="";
username.text=""
password.text=""

View file

@ -36,11 +36,13 @@ import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.4
import "qrc:/js/news.js" as Newsjs
import "qrc:/js/service.js" as Service
import "qrc:/qml/genericqml"
TabView{
id:root
property QtObject osSettings: {var tmp=Qt.createComponent("qrc:/qml/configqml/OSSettingsLinux.qml");return tmp.createObject(root)}
//IntentReceiver{}
tabPosition: Qt.BottomEdge
width: osSettings.appWidth
height:osSettings.appHeight
@ -58,6 +60,7 @@ TabView{
signal contactdetailsSignal(var contact)
signal eventSignal(var contact)
signal uploadSignal(var urls)
signal sendtextSignal(var intenttext)
property var news:[]
property var newContacts:[]
@ -189,5 +192,11 @@ TabView{
id: configtab
source: (root.currentIndex==4)?"qrc:/qml/configqml/ConfigTab.qml":""
}
// Component.onCompleted: {
// var imagePicker = Qt.createQmlObject('import QtQuick 2.0; import "qrc:/qml/genericqml";'+
// osSettings.imagePickQml+'{multiple : true; onReady: {'+
// 'if(imageUrls.length==1){root.currentIndex=0;newstab.active=true;root.uploadSignal(imageUrls)} else{'+
// ' root.currentIndex=2;fotostab.active=true;'+
// 'root.uploadSignal(imageUrls)};}}',root,"imagePicker");
// }
}

View file

@ -0,0 +1,43 @@
import QtQuick 2.0
import AndroidNative 1.0
Item {
/// The URL of the image chosen. If multiple images are picked, it will be equal to the first image.
property string imageUrl: ""
/// A list of images chosen
property var imageUrls: []
property string m_TEXT_MESSAGE: "androidnative.TextIntent.chosen";
property string m_IMAGE_MESSAGE: "androidnative.ImagePicker.chosen";
Connections {
target: SystemDispatcher
onDispatched: {
if (type === m_IMAGE_MESSAGE) {
var h=[];
for (var n in message.imageUrls){
h.push("file://"+ decodeURIComponent(message.imageUrls[n]).substring(5))
}
imageUrls=h;
if(imageUrls.length==1){
root.currentIndex=0;newstab.active=true;
root.uploadSignal(imageUrls)
} else{
root.currentIndex=2;fotostab.active=true;
root.uploadSignal(imageUrls)
}
} else if (type==m_TEXT_MESSAGE){
root.currentIndex=0;newstab.active=true;
root.sendtextSignal(message)
}
}
}
Component.onCompleted: {
SystemDispatcher.setInitialized();
}
}

View file

@ -196,7 +196,7 @@ Rectangle{
anchors.bottomMargin:1
text:"\u2713"
onClicked:{updatePerms();
permissionDialog.destroy();
permissionDialog.visible=false;
}
}

View file

@ -47,6 +47,7 @@ Flickable{
id:messageSend
property string parentId: ""
property string reply_to_user:""
property alias bodyMessage: bodyField.text
property var attachImageURLs: [];
property int directmessage: 0;
property var contacts: []
@ -58,7 +59,8 @@ Flickable{
function attachImage(url){
var imageAttachmentObject=Qt.createQmlObject('import QtQuick 2.0; Image {id:imageAttachment'+attachImageURLs.length+'; source:"'+
url.toString()+'"; width: 15*mm; height: 15*mm;fillMode: Image.PreserveAspectFit;MouseArea{anchors.fill:parent;onClicked:{attachImageURLs.splice(attachImageURLs.indexOf("'+url+'"),1); imageAttachment'+attachImageURLs.length+'.destroy()}}}',messageColumn,"attachedImage");
url.toString()+'"; x:2*mm; width: 45*mm; height: 45*mm;fillMode: Image.PreserveAspectFit;MouseArea{anchors.fill:parent;onClicked:{attachImageURLs.splice(attachImageURLs.indexOf("'+
url+'"),1); imageAttachment'+attachImageURLs.length+'.destroy()}}}',messageColumn,"attachedImage");
}
function statusUpdate(title,status,in_reply_to_status_id,attachImageURL) {
@ -90,7 +92,7 @@ Flickable{
Column {
id:messageColumn
spacing: 2
spacing: 0.5*mm
width: parent.width
TextField {
id: titleField
@ -99,14 +101,23 @@ Flickable{
visible: messageSend.parentId === ""
}
TextArea {
id: bodyField
width: parent.width
height: 30*mm
wrapMode: TextEdit.Wrap
textFormat: TextEdit.PlainText
Rectangle{
color: "white"
radius: 0.5*mm
x:mm
width: parent.width-2*mm
height:Math.max(bodyField.contentHeight+2*mm,10*mm)
TextArea {
id: bodyField
anchors.fill: parent
font.pixelSize: 3*mm
wrapMode: Text.Wrap
selectByMouse: true
textFormat: TextEdit.PlainText
}
}
Row{
spacing: 2
CheckBox{
@ -143,10 +154,9 @@ Flickable{
text:"\u2713"
onClicked: {if(urlTextEdit.text!=""){
var start = bodyField.selectionStart;
var end = bodyField.selectionEnd;
var text = bodyField.getText(start,end);
var text=bodyField.selectedText
text = "[url="+urlTextEdit.text+"]" + text + "[/url]";
bodyField.remove(start,end);
bodyField.remove(start,bodyField.selectionEnd);
bodyField.insert(start,text);}
urlRectangle.visible=false}
}
@ -158,13 +168,11 @@ Flickable{
BlueButton{id:permButton
visible: (directmessage==1)?false:true
text: ((contact_allow.length==0)&&(contact_deny.length==0)&&(group_allow.length==0)&&(group_deny.length==0))?"\uf09c":"\uf023"
onClicked: {
var component = Qt.createComponent("qrc:/qml/genericqml/PermissionDialog.qml");
var permissions = component.createObject(messageColumn);
}}
onClicked: { permissionDialog.visible=true;}
}
BlueButton {
id: attachButton
text: "\uf0c6"
text: "\uf03e"
visible:(directmessage==0)
onClicked: {
if (attachImageURLs.length>0){//Server currently accepts only one attachment
@ -189,27 +197,26 @@ Flickable{
if(Helperjs.getCount(db,login,"contacts","screen_name",contacts[i].screen_name)>1){
contacts[i].screen_name=contacts[i].screen_name+"+"+contacts[i].cid
}
contactitems=contactitems+"MenuItem{text:'"+contacts[i].screen_name+"';iconSource:'"+contacts[i].profile_image+"'; onTriggered: bodyField.insert(0,' @"+contacts[i].screen_name+" ')}"
contactitems=contactitems+"MenuItem{text:'"+contacts[i].screen_name+"'; onTriggered: bodyField.insert(0,' @"+contacts[i].screen_name+" ')}"
}}
var menuString="import QtQuick.Controls 1.4; Menu {"+contactitems+"}";
var contactlistObject=Qt.createQmlObject(menuString,messageSend,"contactmenuOutput")
var contactlistObject=Qt.createQmlObject(menuString,messageColumn,"contactmenuOutput")
contactlistObject.popup() }
}
BlueButton{
id:smileyButton
text: "\uf118"
onClicked: {
var smileyarray=Smileyjs.smileys
var component = Qt.createComponent("qrc:/qml/newsqml/SmileyDialog.qml");
var smileydialog = component.createObject(messageColumn)
}}
onClicked: {smileyDialog.visible=true}
}
BlueButton {
id: cancelButton
text: "\uf057"
onClicked: {newstab.newstabstatus=login.newsViewType;
newsStack.pop(null)}
onClicked: {
newstab.newstabstatus=login.newsViewType;
newsStack.pop(null)
}
}
BlueButton {
id: sendButton
@ -224,7 +231,8 @@ Flickable{
}
}
}
PermissionDialog{id:permissionDialog;x:mm;visible: false}
SmileyDialog{id:smileyDialog;x:mm;visible: false}
}
Component.onCompleted: if(attachImageURLs.length>0){attachImage(attachImageURLs[0])}
}

View file

@ -71,7 +71,7 @@ Item {
function showNews(newsToShow){
try{if (newsStack.depth>1){newsStack.pop()}}catch(e){}
newsBusy.running = false;
newsBusy.running=false;
var currentTime= new Date();
downloadNotice.text="";
var msg = {'currentTime': currentTime, 'model': newsModel,'news':newsToShow};
@ -117,7 +117,14 @@ Item {
function sendUrls(urls){
if((urls.length==1)&&(newsStack.depth<2)){
newsStack.push([newslistRectangle,{item:"qrc:/qml/newsqml/MessageSend.qml",properties:{attachImageURLs:urls}}])
newsStack.push([newslistRectangle,{item:"qrc:/qml/newsqml/MessageSend.qml",properties:{attachImageURLs:urls}}])
}
}
function sendtext(text){
if(text&&(newsStack.depth<2)){
if (text.subject=="undefined"){text.subject=""}
newsStack.push([newslistRectangle,{item:"qrc:/qml/newsqml/MessageSend.qml",properties:{bodyMessage:text.subject+"\n"+text.plaintext}}])
}
}
@ -338,6 +345,7 @@ Item {
root.directmessageSignal.connect(onDirectMessage);
root.newsSignal.connect(showNews);
root.uploadSignal.connect(sendUrls);
root.sendtextSignal.connect(sendtext);
try{newsModel.clear()} catch(e){}
//print("imageUrls "+JSON.stringify(imageUrls)+" newsstack.depth:"+newsStack.depth);

View file

@ -49,7 +49,7 @@ Rectangle{
anchors.right: parent.right
anchors.rightMargin: 1*mm
text: "\uf057"
onClicked:{smileyDialog.destroy()}
onClicked:{smileyDialog.visible=false}
}
TabView{
@ -164,7 +164,8 @@ Rectangle{
MouseArea{
anchors.fill: parent
onClicked:{
bodyField.append(emoji.name+" ")
//bodyField.append(emoji.name+" ")
bodyField.insert(bodyField.cursorPosition,emoji.name+" ");
smileyDialog.destroy()
}
}