cleaned up shared text

This commit is contained in:
Daniel Gultsch 2014-05-21 16:43:19 +02:00
parent 9d2ce5ff98
commit 0de9d57420
6 changed files with 41 additions and 26 deletions

View file

@ -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);
}

View file

@ -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();
}
}

View file

@ -621,6 +621,23 @@ public class ConversationActivity extends XmppActivity {
return super.onKeyDown(keyCode, event);
}
@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();

View file

@ -459,16 +459,12 @@ 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+" ");
}
}
int position = chatMsg.length();
Editable etext = chatMsg.getText();
Selection.setSelection(etext, position);
@ -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();

View file

@ -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();
}
});

View file

@ -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);
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);
}