cleanup. removed old contacts activity. WARNING: this will temporarly disable muc invites
This commit is contained in:
parent
f6649ef838
commit
0193e0291c
|
@ -50,10 +50,20 @@
|
|||
</activity>
|
||||
<activity
|
||||
android:name="eu.siacs.conversations.ui.StartConversation"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:label="@string/title_activity_start_conversation"
|
||||
android:parentActivityName="eu.siacs.conversations.ui.ConversationActivity"
|
||||
android:logo="@drawable/ic_activity"
|
||||
></activity>
|
||||
android:parentActivityName="eu.siacs.conversations.ui.ConversationActivity"
|
||||
android:windowSoftInputMode="stateHidden" >
|
||||
<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
|
||||
android:name="eu.siacs.conversations.ui.SettingsActivity"
|
||||
android:label="@string/title_activity_settings"
|
||||
|
@ -75,24 +85,6 @@
|
|||
android:label="@string/title_activity_contact_details"
|
||||
android:windowSoftInputMode="stateHidden" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name="eu.siacs.conversations.ui.ContactsActivity"
|
||||
android:label="@string/title_activity_contacts"
|
||||
android:parentActivityName="eu.siacs.conversations.ui.ConversationActivity"
|
||||
android:windowSoftInputMode="stateHidden" >
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="de.gultsch.chat.ui.ConversationActivity" />
|
||||
|
||||
<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
|
||||
android:name="eu.siacs.conversations.ui.ShareWithActivity"
|
||||
android:label="@string/title_activity_conversations" >
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#e5e5e5" >
|
||||
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar1"
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/new_conversation_search"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="#eee"
|
||||
android:ems="10"
|
||||
android:hint="@string/search_jabber_id"
|
||||
android:inputType="textEmailAddress"
|
||||
android:paddingBottom="12dp"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:paddingTop="12dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/contacts_header"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Contacts"
|
||||
style="@style/sectionHeader"
|
||||
android:layout_below="@+id/new_conversation_search"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingRight="8dp"/>
|
||||
|
||||
<ListView
|
||||
android:id="@+id/contactList"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_below="@+id/contacts_header"
|
||||
tools:listitem="@layout/contact"
|
||||
android:choiceMode="multipleChoice">
|
||||
|
||||
</ListView>
|
||||
</RelativeLayout>
|
|
@ -1,15 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item
|
||||
android:id="@+id/action_accounts"
|
||||
android:orderInCategory="90"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/action_accounts"
|
||||
/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:orderInCategory="100"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/action_settings"/>
|
||||
</menu>
|
|
@ -1,21 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<item
|
||||
android:id="@+id/action_contact_details"
|
||||
android:showAsAction="ifRoom"
|
||||
android:title="@string/action_contact_details" />
|
||||
<item
|
||||
android:id="@+id/action_start_conversation"
|
||||
android:showAsAction="ifRoom"
|
||||
android:icon="@drawable/ic_action_chat"
|
||||
android:title="@string/start_conversation" />
|
||||
<item
|
||||
android:id="@+id/action_invite"
|
||||
android:showAsAction="ifRoom"
|
||||
android:title="@string/invite_contacts" />
|
||||
<item
|
||||
android:id="@+id/action_invite_to_existing"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/invite_contacts_to_existing" />
|
||||
</menu>
|
|
@ -1,598 +0,0 @@
|
|||
package eu.siacs.conversations.ui;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.entities.Account;
|
||||
import eu.siacs.conversations.entities.Contact;
|
||||
import eu.siacs.conversations.entities.Conversation;
|
||||
import eu.siacs.conversations.utils.CryptoHelper;
|
||||
import eu.siacs.conversations.utils.UIHelper;
|
||||
import eu.siacs.conversations.utils.Validator;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.SparseBooleanArray;
|
||||
import android.view.ActionMode;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.AdapterView.OnItemLongClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.Intent;
|
||||
|
||||
public class ContactsActivity extends XmppActivity {
|
||||
|
||||
protected List<Contact> rosterContacts = new ArrayList<Contact>();
|
||||
protected List<Contact> aggregatedContacts = new ArrayList<Contact>();
|
||||
protected ListView contactsView;
|
||||
protected ArrayAdapter<Contact> contactsAdapter;
|
||||
|
||||
protected EditText search;
|
||||
protected String searchString = "";
|
||||
private TextView contactsHeader;
|
||||
private List<Account> accounts;
|
||||
private List<Contact> selectedContacts = new ArrayList<Contact>();
|
||||
|
||||
private ContactsActivity activity = this;
|
||||
|
||||
private boolean useSubject = true;
|
||||
private boolean isActionMode = false;
|
||||
private boolean inviteIntent = false;
|
||||
private ActionMode actionMode = null;
|
||||
private AbsListView.MultiChoiceModeListener actionModeCallback = new AbsListView.MultiChoiceModeListener() {
|
||||
|
||||
@Override
|
||||
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
|
||||
menu.clear();
|
||||
MenuInflater inflater = mode.getMenuInflater();
|
||||
inflater.inflate(R.menu.newconversation_context, menu);
|
||||
SparseBooleanArray checkedItems = contactsView
|
||||
.getCheckedItemPositions();
|
||||
selectedContacts.clear();
|
||||
for (int i = 0; i < aggregatedContacts.size(); ++i) {
|
||||
if (checkedItems.get(i, false)) {
|
||||
selectedContacts.add(aggregatedContacts.get(i));
|
||||
}
|
||||
}
|
||||
if (selectedContacts.size() == 0) {
|
||||
menu.findItem(R.id.action_start_conversation).setVisible(false);
|
||||
menu.findItem(R.id.action_contact_details).setVisible(false);
|
||||
menu.findItem(R.id.action_invite).setVisible(false);
|
||||
menu.findItem(R.id.action_invite_to_existing).setVisible(false);
|
||||
} else if ((selectedContacts.size() == 1) && (!inviteIntent)) {
|
||||
menu.findItem(R.id.action_start_conversation).setVisible(true);
|
||||
menu.findItem(R.id.action_contact_details).setVisible(true);
|
||||
menu.findItem(R.id.action_invite).setVisible(false);
|
||||
menu.findItem(R.id.action_invite_to_existing).setVisible(true);
|
||||
} else if (!inviteIntent) {
|
||||
menu.findItem(R.id.action_start_conversation).setVisible(true);
|
||||
menu.findItem(R.id.action_contact_details).setVisible(false);
|
||||
menu.findItem(R.id.action_invite).setVisible(false);
|
||||
menu.findItem(R.id.action_invite_to_existing).setVisible(true);
|
||||
} else {
|
||||
menu.findItem(R.id.action_invite).setVisible(true);
|
||||
menu.findItem(R.id.action_start_conversation).setVisible(false);
|
||||
menu.findItem(R.id.action_contact_details).setVisible(false);
|
||||
menu.findItem(R.id.action_invite_to_existing).setVisible(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyActionMode(ActionMode mode) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_start_conversation:
|
||||
if (selectedContacts.size() == 1) {
|
||||
startConversation(selectedContacts.get(0));
|
||||
} else {
|
||||
startConference();
|
||||
}
|
||||
break;
|
||||
case R.id.action_contact_details:
|
||||
Intent intent = new Intent(getApplicationContext(),
|
||||
ContactDetailsActivity.class);
|
||||
intent.setAction(ContactDetailsActivity.ACTION_VIEW_CONTACT);
|
||||
intent.putExtra("account", selectedContacts.get(0).getAccount().getJid());
|
||||
intent.putExtra("contact",selectedContacts.get(0).getJid());
|
||||
startActivity(intent);
|
||||
finish();
|
||||
break;
|
||||
case R.id.action_invite:
|
||||
invite();
|
||||
break;
|
||||
case R.id.action_invite_to_existing:
|
||||
final List<Conversation> mucs = new ArrayList<Conversation>();
|
||||
for(Conversation conv : xmppConnectionService.getConversations()) {
|
||||
if (conv.getMode() == Conversation.MODE_MULTI) {
|
||||
mucs.add(conv);
|
||||
}
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setTitle(getString(R.string.invite_contacts_to_existing));
|
||||
if (mucs.size() >= 1) {
|
||||
String[] options = new String[mucs.size()];
|
||||
for(int i = 0; i < options.length; ++i) {
|
||||
options[i] = mucs.get(i).getName(useSubject);
|
||||
}
|
||||
builder.setItems(options, new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Conversation conversation = mucs.get(which);
|
||||
if (isOnline(conversation.getAccount())) {
|
||||
xmppConnectionService.inviteToConference(conversation, selectedContacts);
|
||||
Toast.makeText(activity, getString(R.string.invitation_sent), Toast.LENGTH_SHORT).show();
|
||||
actionMode.finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
builder.setMessage(getString(R.string.no_open_mucs));
|
||||
}
|
||||
builder.setNegativeButton(getString(R.string.cancel),null);
|
||||
builder.create().show();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemCheckedStateChanged(ActionMode mode, int position,
|
||||
long id, boolean checked) {
|
||||
}
|
||||
};
|
||||
|
||||
private boolean isOnline(Account account) {
|
||||
if (account.getStatus() == Account.STATUS_ONLINE) {
|
||||
return true;
|
||||
} else {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle(getString(R.string.account_offline));
|
||||
builder.setMessage(getString(R.string.cant_invite_while_offline));
|
||||
builder.setNegativeButton(getString(R.string.ok), null);
|
||||
builder.setIconAttribute(android.R.attr.alertDialogIcon);
|
||||
builder.create().show();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void invite() {
|
||||
List<Conversation> conversations = xmppConnectionService
|
||||
.getConversations();
|
||||
Conversation conversation = null;
|
||||
for (Conversation tmpConversation : conversations) {
|
||||
if (tmpConversation.getUuid().equals(
|
||||
getIntent().getStringExtra("uuid"))) {
|
||||
conversation = tmpConversation;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (conversation != null) {
|
||||
xmppConnectionService.inviteToConference(conversation,
|
||||
selectedContacts);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
private void startConference() {
|
||||
if (accounts.size() > 1) {
|
||||
getAccountChooser(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
startConference(accounts.get(which));
|
||||
}
|
||||
}).show();
|
||||
} else {
|
||||
startConference(accounts.get(0));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void startConference(final Account account) {
|
||||
if (isOnline(account)) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle(getString(R.string.new_conference));
|
||||
builder.setMessage(getString(R.string.new_conference_explained));
|
||||
builder.setNegativeButton(getString(R.string.cancel), null);
|
||||
builder.setPositiveButton(getString(R.string.create_invite),
|
||||
new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
String mucName = CryptoHelper.randomMucName(xmppConnectionService.getRNG());
|
||||
String serverName = account.getXmppConnection()
|
||||
.getMucServer();
|
||||
if (serverName==null) {
|
||||
List<String> servers = getMucServers();
|
||||
if (servers.size() >= 1) {
|
||||
serverName = servers.get(0);
|
||||
} else {
|
||||
displayErrorDialog(R.string.no_muc_server_found);
|
||||
return;
|
||||
}
|
||||
}
|
||||
String jid = mucName + "@" + serverName;
|
||||
Conversation conversation = xmppConnectionService
|
||||
.findOrCreateConversation(account, jid, true);
|
||||
StringBuilder subject = new StringBuilder();
|
||||
subject.append(account.getUsername() + ", ");
|
||||
for (int i = 0; i < selectedContacts.size(); ++i) {
|
||||
if (i + 1 != selectedContacts.size()) {
|
||||
subject.append(selectedContacts.get(i)
|
||||
.getDisplayName() + ", ");
|
||||
} else {
|
||||
subject.append(selectedContacts.get(i)
|
||||
.getDisplayName());
|
||||
}
|
||||
}
|
||||
xmppConnectionService.sendConversationSubject(
|
||||
conversation, subject.toString());
|
||||
xmppConnectionService.inviteToConference(conversation,
|
||||
selectedContacts);
|
||||
switchToConversation(conversation, null,false);
|
||||
}
|
||||
});
|
||||
builder.create().show();
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateAggregatedContacts() {
|
||||
|
||||
aggregatedContacts.clear();
|
||||
for (Contact contact : rosterContacts) {
|
||||
if (contact.match(searchString)&&(contact.showInRoster()))
|
||||
aggregatedContacts.add(contact);
|
||||
}
|
||||
|
||||
Collections.sort(aggregatedContacts, new Comparator<Contact>() {
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
@Override
|
||||
public int compare(Contact lhs, Contact rhs) {
|
||||
return lhs.getDisplayName().toLowerCase()
|
||||
.compareTo(rhs.getDisplayName().toLowerCase());
|
||||
}
|
||||
});
|
||||
|
||||
if (aggregatedContacts.size() == 0) {
|
||||
|
||||
if (Validator.isValidJid(searchString)) {
|
||||
Contact newContact = new Contact(searchString);
|
||||
newContact.resetOption(Contact.Options.IN_ROSTER);
|
||||
aggregatedContacts.add(newContact);
|
||||
contactsHeader.setText(getString(R.string.new_contact));
|
||||
} else {
|
||||
contactsHeader.setText(getString(R.string.contacts));
|
||||
}
|
||||
} else {
|
||||
contactsHeader.setText(getString(R.string.contacts));
|
||||
}
|
||||
|
||||
contactsAdapter.notifyDataSetChanged();
|
||||
contactsView.setScrollX(0);
|
||||
}
|
||||
|
||||
private OnItemLongClickListener onLongClickListener = new OnItemLongClickListener() {
|
||||
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> arg0, View view,
|
||||
int position, long arg3) {
|
||||
if (!isActionMode) {
|
||||
contactsView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
|
||||
contactsView.setItemChecked(position, true);
|
||||
actionMode = contactsView.startActionMode(actionModeCallback);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||
this.useSubject = preferences.getBoolean("use_subject_in_muc", true);
|
||||
inviteIntent = "invite".equals(getIntent().getAction());
|
||||
if (inviteIntent) {
|
||||
contactsHeader.setVisibility(View.GONE);
|
||||
actionMode = contactsView.startActionMode(actionModeCallback);
|
||||
search.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setContentView(R.layout.activity_new_conversation);
|
||||
|
||||
contactsHeader = (TextView) findViewById(R.id.contacts_header);
|
||||
|
||||
search = (EditText) findViewById(R.id.new_conversation_search);
|
||||
search.addTextChangedListener(new TextWatcher() {
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before,
|
||||
int count) {
|
||||
searchString = search.getText().toString();
|
||||
updateAggregatedContacts();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count,
|
||||
int after) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
contactsView = (ListView) findViewById(R.id.contactList);
|
||||
contactsAdapter = new ArrayAdapter<Contact>(getApplicationContext(),
|
||||
R.layout.contact, aggregatedContacts) {
|
||||
@Override
|
||||
public View getView(int position, View view, ViewGroup parent) {
|
||||
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
Contact contact = getItem(position);
|
||||
if (view == null) {
|
||||
view = (View) inflater.inflate(R.layout.contact, null);
|
||||
}
|
||||
|
||||
((TextView) view.findViewById(R.id.contact_display_name))
|
||||
.setText(getItem(position).getDisplayName());
|
||||
TextView contactJid = (TextView) view
|
||||
.findViewById(R.id.contact_jid);
|
||||
contactJid.setText(contact.getJid());
|
||||
ImageView imageView = (ImageView) view
|
||||
.findViewById(R.id.contact_photo);
|
||||
imageView.setImageBitmap(UIHelper.getContactPicture(contact, 48, this.getContext(), false));
|
||||
return view;
|
||||
}
|
||||
};
|
||||
contactsView.setAdapter(contactsAdapter);
|
||||
contactsView.setMultiChoiceModeListener(actionModeCallback);
|
||||
contactsView.setOnItemClickListener(new OnItemClickListener() {
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> arg0, final View view,
|
||||
int pos, long arg3) {
|
||||
if (!isActionMode) {
|
||||
Contact clickedContact = aggregatedContacts.get(pos);
|
||||
startConversation(clickedContact);
|
||||
|
||||
} else {
|
||||
actionMode.invalidate();
|
||||
}
|
||||
}
|
||||
});
|
||||
contactsView.setOnItemLongClickListener(this.onLongClickListener);
|
||||
}
|
||||
|
||||
public void startConversation(final Contact contact) {
|
||||
if ((contact.getAccount() == null) && (accounts.size() > 1)) {
|
||||
getAccountChooser(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
contact.setAccount(accounts.get(which));
|
||||
showIsMucDialogIfNeeded(contact);
|
||||
}
|
||||
}).show();
|
||||
} else {
|
||||
if (contact.getAccount() == null) {
|
||||
contact.setAccount(accounts.get(0));
|
||||
}
|
||||
showIsMucDialogIfNeeded(contact);
|
||||
}
|
||||
}
|
||||
|
||||
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(getString(R.string.choose_account));
|
||||
accountChooser.setItems(accountList, listener);
|
||||
return accountChooser.create();
|
||||
}
|
||||
|
||||
public void showIsMucDialogIfNeeded(final Contact clickedContact) {
|
||||
if (isMuc(clickedContact)) {
|
||||
startConversation(clickedContact,clickedContact.getAccount(), true);
|
||||
} else if (clickedContact.couldBeMuc()) {
|
||||
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
|
||||
dialog.setTitle(getString(R.string.multi_user_conference));
|
||||
dialog.setMessage(getString(R.string.trying_join_conference));
|
||||
dialog.setPositiveButton(getString(R.string.yes), new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
startConversation(clickedContact,
|
||||
clickedContact.getAccount(), true);
|
||||
}
|
||||
});
|
||||
dialog.setNegativeButton(getString(R.string.no), new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
startConversation(clickedContact,
|
||||
clickedContact.getAccount(), false);
|
||||
}
|
||||
});
|
||||
dialog.create().show();
|
||||
} else {
|
||||
startConversation(clickedContact, clickedContact.getAccount(),
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> getMucServers() {
|
||||
ArrayList<String> mucServers = new ArrayList<String>();
|
||||
for(Account account : accounts) {
|
||||
if (account.getXmppConnection()!=null) {
|
||||
String server = account.getXmppConnection().getMucServer();
|
||||
if (server!=null) {
|
||||
mucServers.add(server);
|
||||
}
|
||||
}
|
||||
}
|
||||
return mucServers;
|
||||
}
|
||||
|
||||
private boolean isMuc(Contact contact) {
|
||||
String[] parts = contact.getJid().split("@");
|
||||
if (parts.length != 2) {
|
||||
return false;
|
||||
}
|
||||
return getMucServers().contains(parts[1]);
|
||||
}
|
||||
|
||||
public void startConversation(Contact contact, Account account, boolean muc) {
|
||||
if (!contact.getOption(Contact.Options.IN_ROSTER)&&(!muc)) {
|
||||
xmppConnectionService.createContact(contact);
|
||||
}
|
||||
Conversation conversation = xmppConnectionService
|
||||
.findOrCreateConversation(account, contact.getJid(), muc);
|
||||
|
||||
switchToConversation(conversation, null,false);
|
||||
}
|
||||
|
||||
@Override
|
||||
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, null,false);
|
||||
finish();
|
||||
}
|
||||
}).show();
|
||||
} else {
|
||||
Conversation conversation = xmppConnectionService
|
||||
.findOrCreateConversation(this.accounts.get(0),
|
||||
jid, false);
|
||||
switchToConversation(conversation, null,false);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (xmppConnectionService.getConversationCount() == 0) {
|
||||
getActionBar().setDisplayHomeAsUpEnabled(false);
|
||||
getActionBar().setHomeButtonEnabled(false);
|
||||
}
|
||||
this.rosterContacts.clear();
|
||||
for(Account account : accounts) {
|
||||
if (account.getStatus() != Account.STATUS_DISABLED) {
|
||||
rosterContacts.addAll(account.getRoster().getContacts());
|
||||
}
|
||||
}
|
||||
updateAggregatedContacts();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.newconversation, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActionModeStarted(ActionMode mode) {
|
||||
super.onActionModeStarted(mode);
|
||||
this.isActionMode = true;
|
||||
search.setEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActionModeFinished(ActionMode mode) {
|
||||
super.onActionModeFinished(mode);
|
||||
if (inviteIntent) {
|
||||
finish();
|
||||
} else {
|
||||
this.isActionMode = false;
|
||||
contactsView.clearChoices();
|
||||
contactsView.requestLayout();
|
||||
contactsView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
contactsView.setChoiceMode(ListView.CHOICE_MODE_NONE);
|
||||
}
|
||||
});
|
||||
search.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -97,7 +97,7 @@ public class ConversationActivity extends XmppActivity {
|
|||
swapConversationFragment();
|
||||
} else {
|
||||
startActivity(new Intent(getApplicationContext(),
|
||||
ContactsActivity.class));
|
||||
StartConversation.class));
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
@ -419,37 +419,6 @@ public class ConversationActivity extends XmppActivity {
|
|||
selectPresenceToAttachFile(attachmentChoice);
|
||||
} else {
|
||||
selectPresenceToAttachFile(attachmentChoice);
|
||||
/*AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle(getString(R.string.otr_file_transfer));
|
||||
builder.setMessage(getString(R.string.otr_file_transfer_msg));
|
||||
builder.setNegativeButton(getString(R.string.cancel), null);
|
||||
if (conversation.getContact().getPgpKeyId() == 0) {
|
||||
builder.setPositiveButton(getString(R.string.send_unencrypted),
|
||||
new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog,
|
||||
int which) {
|
||||
conversation
|
||||
.setNextEncryption(Message.ENCRYPTION_NONE);
|
||||
attachFile(attachmentChoice);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
builder.setPositiveButton(
|
||||
getString(R.string.use_pgp_encryption),
|
||||
new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog,
|
||||
int which) {
|
||||
conversation
|
||||
.setNextEncryption(Message.ENCRYPTION_PGP);
|
||||
attachFile(attachmentChoice);
|
||||
}
|
||||
});
|
||||
}
|
||||
builder.create().show();*/
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -508,11 +477,11 @@ public class ConversationActivity extends XmppActivity {
|
|||
startActivity(intent);
|
||||
break;
|
||||
case R.id.action_invite:
|
||||
Intent inviteIntent = new Intent(getApplicationContext(),
|
||||
/*Intent inviteIntent = new Intent(getApplicationContext(),
|
||||
ContactsActivity.class);
|
||||
inviteIntent.setAction("invite");
|
||||
inviteIntent.putExtra("uuid", getSelectedConversation().getUuid());
|
||||
startActivity(inviteIntent);
|
||||
startActivity(inviteIntent);*/
|
||||
break;
|
||||
case R.id.action_security:
|
||||
final Conversation conversation = getSelectedConversation();
|
||||
|
@ -729,7 +698,7 @@ public class ConversationActivity extends XmppActivity {
|
|||
finish();
|
||||
} else if (conversationList.size() <= 0) {
|
||||
// add no history
|
||||
startActivity(new Intent(this, ContactsActivity.class));
|
||||
startActivity(new Intent(this, StartConversation.class));
|
||||
finish();
|
||||
} else {
|
||||
spl.openPane();
|
||||
|
|
|
@ -195,7 +195,7 @@ public class ManageAccountActivity extends XmppActivity {
|
|||
if ((account.getStatus() == Account.STATUS_OFFLINE)||(account.getStatus() == Account.STATUS_TLS_ERROR)) {
|
||||
activity.xmppConnectionService.reconnectAccount(accountList.get(position),true);
|
||||
} else if (account.getStatus() == Account.STATUS_ONLINE) {
|
||||
activity.startActivity(new Intent(activity.getApplicationContext(),ContactsActivity.class));
|
||||
activity.startActivity(new Intent(activity.getApplicationContext(),StartConversation.class));
|
||||
} else if (account.getStatus() != Account.STATUS_DISABLED) {
|
||||
editAccount(account);
|
||||
}
|
||||
|
@ -403,7 +403,7 @@ public class ManageAccountActivity extends XmppActivity {
|
|||
@Override
|
||||
public boolean onNavigateUp() {
|
||||
if (xmppConnectionService.getConversations().size() == 0) {
|
||||
Intent contactsIntent = new Intent(this, ContactsActivity.class);
|
||||
Intent contactsIntent = new Intent(this, StartConversation.class);
|
||||
contactsIntent.setFlags(
|
||||
// if activity exists in stack, pop the stack and go back to it
|
||||
Intent.FLAG_ACTIVITY_CLEAR_TOP |
|
||||
|
|
|
@ -72,11 +72,11 @@ public class MucDetailsActivity extends XmppActivity {
|
|||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getApplicationContext(),
|
||||
/*Intent intent = new Intent(getApplicationContext(),
|
||||
ContactsActivity.class);
|
||||
intent.setAction("invite");
|
||||
intent.putExtra("uuid",conversation.getUuid());
|
||||
startActivity(intent);
|
||||
startActivity(intent);*/
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ import android.graphics.Bitmap;
|
|||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.ImageView;
|
||||
|
|
|
@ -45,7 +45,6 @@ import android.text.Html;
|
|||
import android.util.DisplayMetrics;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.QuickContactBadge;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
|
Loading…
Reference in a new issue