start converstaion from address book (sendto)
This commit is contained in:
parent
678dbd37c6
commit
748582e3ab
|
@ -11,10 +11,10 @@
|
||||||
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
<uses-permission android:name="android.permission.READ_CONTACTS" />
|
||||||
<uses-permission android:name="android.permission.READ_PROFILE" />
|
<uses-permission android:name="android.permission.READ_PROFILE" />
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
<uses-permission android:name="android.permission.VIBRATE"/>
|
<uses-permission android:name="android.permission.VIBRATE" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
<receiver android:name="eu.siacs.conversations.services.EventReceiver" >
|
<receiver android:name="eu.siacs.conversations.services.EventReceiver" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||||
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
|
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
|
@ -40,14 +40,6 @@
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.SENDTO" />
|
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
|
||||||
|
|
||||||
<data android:scheme="imto" />
|
|
||||||
<data android:host="jabber" />
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name="eu.siacs.conversations.ui.SettingsActivity"
|
android:name="eu.siacs.conversations.ui.SettingsActivity"
|
||||||
|
@ -77,6 +69,18 @@
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
android:value="de.gultsch.chat.ui.ConversationActivity" />
|
android:value="de.gultsch.chat.ui.ConversationActivity" />
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.SEND" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<data android:mimeType="text/plain" />
|
||||||
|
</intent-filter>
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.SENDTO" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<data android:scheme="imto" />
|
||||||
|
<data android:host="jabber" />
|
||||||
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
package eu.siacs.conversations.ui;
|
package eu.siacs.conversations.ui;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URLDecoder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
import eu.siacs.conversations.entities.Account;
|
import eu.siacs.conversations.entities.Account;
|
||||||
|
@ -15,6 +18,7 @@ import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
@ -151,23 +155,14 @@ public class NewConversationActivity extends XmppActivity {
|
||||||
final Contact clickedContact = aggregatedContacts.get(pos);
|
final Contact clickedContact = aggregatedContacts.get(pos);
|
||||||
|
|
||||||
if ((clickedContact.getAccount()==null)&&(accounts.size()>1)) {
|
if ((clickedContact.getAccount()==null)&&(accounts.size()>1)) {
|
||||||
String[] accountList = new String[accounts.size()];
|
getAccountChooser(new OnClickListener() {
|
||||||
for (int i = 0; i < accounts.size(); ++i) {
|
|
||||||
accountList[i] = accounts.get(i).getJid();
|
|
||||||
}
|
|
||||||
|
|
||||||
AlertDialog.Builder accountChooser = new AlertDialog.Builder(
|
|
||||||
activity);
|
|
||||||
accountChooser.setTitle("Choose account");
|
|
||||||
accountChooser.setItems(accountList, new OnClickListener() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
clickedContact.setAccount(accounts.get(which));
|
clickedContact.setAccount(accounts.get(which));
|
||||||
showIsMucDialogIfNeeded(clickedContact);
|
showIsMucDialogIfNeeded(clickedContact);
|
||||||
}
|
}
|
||||||
});
|
}).show();
|
||||||
accountChooser.create().show();
|
|
||||||
} else {
|
} else {
|
||||||
if (clickedContact.getAccount()==null) {
|
if (clickedContact.getAccount()==null) {
|
||||||
clickedContact.setAccount(accounts.get(0));
|
clickedContact.setAccount(accounts.get(0));
|
||||||
|
@ -190,6 +185,19 @@ public class NewConversationActivity extends XmppActivity {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected AlertDialog getAccountChooser(OnClickListener listener) {
|
||||||
|
String[] accountList = new String[accounts.size()];
|
||||||
|
for (int i = 0; i < accounts.size(); ++i) {
|
||||||
|
accountList[i] = accounts.get(i).getJid();
|
||||||
|
}
|
||||||
|
|
||||||
|
AlertDialog.Builder accountChooser = new AlertDialog.Builder(
|
||||||
|
this);
|
||||||
|
accountChooser.setTitle("Choose account");
|
||||||
|
accountChooser.setItems(accountList, listener);
|
||||||
|
return accountChooser.create();
|
||||||
|
}
|
||||||
|
|
||||||
public void showIsMucDialogIfNeeded(final Contact clickedContact) {
|
public void showIsMucDialogIfNeeded(final Contact clickedContact) {
|
||||||
if (clickedContact.couldBeMuc()) {
|
if (clickedContact.couldBeMuc()) {
|
||||||
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
|
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
|
||||||
|
@ -222,6 +230,10 @@ public class NewConversationActivity extends XmppActivity {
|
||||||
Conversation conversation = xmppConnectionService
|
Conversation conversation = xmppConnectionService
|
||||||
.findOrCreateConversation(account, contact.getJid(), muc);
|
.findOrCreateConversation(account, contact.getJid(), muc);
|
||||||
|
|
||||||
|
switchToConversation(conversation);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void switchToConversation(Conversation conversation) {
|
||||||
Intent viewConversationIntent = new Intent(this,
|
Intent viewConversationIntent = new Intent(this,
|
||||||
ConversationActivity.class);
|
ConversationActivity.class);
|
||||||
viewConversationIntent.setAction(Intent.ACTION_VIEW);
|
viewConversationIntent.setAction(Intent.ACTION_VIEW);
|
||||||
|
@ -235,11 +247,39 @@ public class NewConversationActivity extends XmppActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void onBackendConnected() {
|
void onBackendConnected() {
|
||||||
|
this.accounts = xmppConnectionService.getAccounts();
|
||||||
|
if (Intent.ACTION_SENDTO.equals(getIntent().getAction())) {
|
||||||
|
getActionBar().setDisplayHomeAsUpEnabled(false);
|
||||||
|
getActionBar().setHomeButtonEnabled(false);
|
||||||
|
String jid;
|
||||||
|
try {
|
||||||
|
jid = URLDecoder.decode(getIntent().getData().getEncodedPath(),"UTF-8").split("/")[1];
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
jid = null;
|
||||||
|
}
|
||||||
|
if (jid!=null) {
|
||||||
|
final String finalJid = jid;
|
||||||
|
if (this.accounts.size() > 1) {
|
||||||
|
getAccountChooser(new OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
Conversation conversation = xmppConnectionService.findOrCreateConversation(accounts.get(which), finalJid, false);
|
||||||
|
switchToConversation(conversation);
|
||||||
|
}
|
||||||
|
}).show();
|
||||||
|
} else {
|
||||||
|
Conversation conversation = xmppConnectionService.findOrCreateConversation(this.accounts.get(0), jid, false);
|
||||||
|
switchToConversation(conversation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (xmppConnectionService.getConversationCount() == 0) {
|
if (xmppConnectionService.getConversationCount() == 0) {
|
||||||
getActionBar().setDisplayHomeAsUpEnabled(false);
|
getActionBar().setDisplayHomeAsUpEnabled(false);
|
||||||
getActionBar().setHomeButtonEnabled(false);
|
getActionBar().setHomeButtonEnabled(false);
|
||||||
}
|
}
|
||||||
this.accounts = xmppConnectionService.getAccounts();
|
|
||||||
this.rosterContacts.clear();
|
this.rosterContacts.clear();
|
||||||
for (int i = 0; i < accounts.size(); ++i) {
|
for (int i = 0; i < accounts.size(); ++i) {
|
||||||
xmppConnectionService.getRoster(accounts.get(i),
|
xmppConnectionService.getRoster(accounts.get(i),
|
||||||
|
|
Loading…
Reference in a new issue