aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2014-05-21 16:43:19 +0200
committerDaniel Gultsch <daniel@gultsch.de>2014-05-21 16:43:19 +0200
commit0de9d57420e74282b09b7963017137fd32c98876 (patch)
treeb39c000876dda9329da6e70748673f6948983f27 /src
parent9d2ce5ff980d8469ee48efc25d645f2c9ca399c0 (diff)
cleaned up shared text
Diffstat (limited to 'src')
-rw-r--r--src/eu/siacs/conversations/services/XmppConnectionService.java10
-rw-r--r--src/eu/siacs/conversations/ui/ContactsActivity.java8
-rw-r--r--src/eu/siacs/conversations/ui/ConversationActivity.java17
-rw-r--r--src/eu/siacs/conversations/ui/ConversationFragment.java20
-rw-r--r--src/eu/siacs/conversations/ui/ShareWithActivity.java4
-rw-r--r--src/eu/siacs/conversations/ui/XmppActivity.java8
6 files changed, 41 insertions, 26 deletions
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index 9ea7f2b1f..5abd27705 100644
--- a/src/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/eu/siacs/conversations/services/XmppConnectionService.java
@@ -508,7 +508,7 @@ public class XmppConnectionService extends Service {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
this.wakeLock.acquire();
- if ((intent.getAction()!=null)&&(intent.getAction().equals(ACTION_MERGE_PHONE_CONTACTS))) {
+ if ((intent!=null)&&(intent.getAction()!=null)&&(intent.getAction().equals(ACTION_MERGE_PHONE_CONTACTS))) {
mergePhoneContactsWithRoster();
}
ConnectivityManager cm = (ConnectivityManager) getApplicationContext()
@@ -1209,42 +1209,34 @@ public class XmppConnectionService extends Service {
}
public void requestPresenceUpdatesFrom(Contact contact) {
- // Requesting a Subscription type=subscribe
PresencePacket packet = new PresencePacket();
packet.setAttribute("type", "subscribe");
packet.setAttribute("to", contact.getJid());
packet.setAttribute("from", contact.getAccount().getJid());
- Log.d(LOGTAG, packet.toString());
contact.getAccount().getXmppConnection().sendPresencePacket(packet);
}
public void stopPresenceUpdatesFrom(Contact contact) {
- // Unsubscribing type='unsubscribe'
PresencePacket packet = new PresencePacket();
packet.setAttribute("type", "unsubscribe");
packet.setAttribute("to", contact.getJid());
packet.setAttribute("from", contact.getAccount().getJid());
- Log.d(LOGTAG, packet.toString());
contact.getAccount().getXmppConnection().sendPresencePacket(packet);
}
public void stopPresenceUpdatesTo(Contact contact) {
- // Canceling a Subscription type=unsubscribed
PresencePacket packet = new PresencePacket();
packet.setAttribute("type", "unsubscribed");
packet.setAttribute("to", contact.getJid());
packet.setAttribute("from", contact.getAccount().getJid());
- Log.d(LOGTAG, packet.toString());
contact.getAccount().getXmppConnection().sendPresencePacket(packet);
}
public void sendPresenceUpdatesTo(Contact contact) {
- // type='subscribed'
PresencePacket packet = new PresencePacket();
packet.setAttribute("type", "subscribed");
packet.setAttribute("to", contact.getJid());
packet.setAttribute("from", contact.getAccount().getJid());
- Log.d(LOGTAG, packet.toString());
contact.getAccount().getXmppConnection().sendPresencePacket(packet);
contact.resetOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST);
}
diff --git a/src/eu/siacs/conversations/ui/ContactsActivity.java b/src/eu/siacs/conversations/ui/ContactsActivity.java
index d703b172e..ca794b305 100644
--- a/src/eu/siacs/conversations/ui/ContactsActivity.java
+++ b/src/eu/siacs/conversations/ui/ContactsActivity.java
@@ -258,7 +258,7 @@ public class ContactsActivity extends XmppActivity {
conversation, subject.toString());
xmppConnectionService.inviteToConference(conversation,
selectedContacts);
- switchToConversation(conversation, null);
+ switchToConversation(conversation, null,false);
}
});
builder.create().show();
@@ -467,7 +467,7 @@ public class ContactsActivity extends XmppActivity {
Conversation conversation = xmppConnectionService
.findOrCreateConversation(account, contact.getJid(), muc);
- switchToConversation(conversation, null);
+ switchToConversation(conversation, null,false);
}
@Override
@@ -494,7 +494,7 @@ public class ContactsActivity extends XmppActivity {
.findOrCreateConversation(
accounts.get(which), finalJid,
false);
- switchToConversation(conversation, null);
+ switchToConversation(conversation, null,false);
finish();
}
}).show();
@@ -502,7 +502,7 @@ public class ContactsActivity extends XmppActivity {
Conversation conversation = xmppConnectionService
.findOrCreateConversation(this.accounts.get(0),
jid, false);
- switchToConversation(conversation, null);
+ switchToConversation(conversation, null,false);
finish();
}
}
diff --git a/src/eu/siacs/conversations/ui/ConversationActivity.java b/src/eu/siacs/conversations/ui/ConversationActivity.java
index f19959352..bf83990a3 100644
--- a/src/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/eu/siacs/conversations/ui/ConversationActivity.java
@@ -622,6 +622,23 @@ public class ConversationActivity extends XmppActivity {
}
@Override
+ protected void onNewIntent (Intent intent) {
+ if ((Intent.ACTION_VIEW.equals(intent.getAction())&&(VIEW_CONVERSATION.equals(intent.getType())))) {
+ String convToView = (String) intent.getExtras().get(
+ CONVERSATION);
+
+ for (int i = 0; i < conversationList.size(); ++i) {
+ if (conversationList.get(i).getUuid().equals(convToView)) {
+ setSelectedConversation(conversationList.get(i));
+ }
+ }
+ paneShouldBeOpen = false;
+ String text = intent.getExtras().getString(TEXT, null);
+ swapConversationFragment().setText(text);
+ }
+ }
+
+ @Override
public void onStart() {
super.onStart();
SharedPreferences preferences = PreferenceManager
diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java
index 41837d8fd..44d1848fe 100644
--- a/src/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/eu/siacs/conversations/ui/ConversationFragment.java
@@ -459,15 +459,11 @@ public class ConversationFragment extends Fragment {
}
protected void highlightInConference(String nick) {
- if (chatMsg.getText().toString().isEmpty()) {
+ String oldString = chatMsg.getText().toString().trim();
+ if (oldString.isEmpty()) {
chatMsg.setText(nick+": ");
} else {
- String oldString = chatMsg.getText().toString();
- if (oldString.endsWith(" ")) {
- chatMsg.setText(oldString+nick+" ");
- } else {
- chatMsg.setText(oldString+" "+nick+" ");
- }
+ chatMsg.setText(oldString+" "+nick+" ");
}
int position = chatMsg.length();
Editable etext = chatMsg.getText();
@@ -510,10 +506,16 @@ public class ConversationFragment extends Fragment {
if (this.conversation == null) {
return;
}
+ String oldString = conversation.getNextMessage().trim();
if (this.pastedText == null) {
- this.chatMsg.setText(conversation.getNextMessage());
+ this.chatMsg.setText(oldString);
} else {
- chatMsg.setText(conversation.getNextMessage() + " " + pastedText);
+
+ if (oldString.isEmpty()) {
+ chatMsg.setText(pastedText);
+ } else {
+ chatMsg.setText(oldString + " " + pastedText);
+ }
pastedText = null;
}
int position = chatMsg.length();
diff --git a/src/eu/siacs/conversations/ui/ShareWithActivity.java b/src/eu/siacs/conversations/ui/ShareWithActivity.java
index e4abfd2df..e2188c486 100644
--- a/src/eu/siacs/conversations/ui/ShareWithActivity.java
+++ b/src/eu/siacs/conversations/ui/ShareWithActivity.java
@@ -80,7 +80,7 @@ public class ShareWithActivity extends XmppActivity {
@Override
public void onClick(View v) {
String sharedText = getIntent().getStringExtra(Intent.EXTRA_TEXT);
- switchToConversation(conversation, sharedText);
+ switchToConversation(conversation, sharedText,true);
finish();
}
});
@@ -114,7 +114,7 @@ public class ShareWithActivity extends XmppActivity {
public void onClick(View v) {
String sharedText = getIntent().getStringExtra(Intent.EXTRA_TEXT);
Conversation conversation = xmppConnectionService.findOrCreateConversation(con.getAccount(), con.getJid(), false);
- switchToConversation(conversation, sharedText);
+ switchToConversation(conversation, sharedText,true);
finish();
}
});
diff --git a/src/eu/siacs/conversations/ui/XmppActivity.java b/src/eu/siacs/conversations/ui/XmppActivity.java
index 02900ac8c..7c8c46b2a 100644
--- a/src/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/eu/siacs/conversations/ui/XmppActivity.java
@@ -145,7 +145,7 @@ public abstract class XmppActivity extends Activity {
ExceptionHelper.init(getApplicationContext());
}
- public void switchToConversation(Conversation conversation, String text) {
+ public void switchToConversation(Conversation conversation, String text, boolean newTask) {
Intent viewConversationIntent = new Intent(this,
ConversationActivity.class);
viewConversationIntent.setAction(Intent.ACTION_VIEW);
@@ -155,8 +155,12 @@ public abstract class XmppActivity extends Activity {
viewConversationIntent.putExtra(ConversationActivity.TEXT, text);
}
viewConversationIntent.setType(ConversationActivity.VIEW_CONVERSATION);
- viewConversationIntent.setFlags(viewConversationIntent.getFlags()
+ if (newTask) {
+ viewConversationIntent.setFlags(viewConversationIntent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_TASK_ON_HOME );
+ } else {
+ viewConversationIntent.setFlags(viewConversationIntent.getFlags()
| Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ }
startActivity(viewConversationIntent);
}