mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-28 03:32:15 -05:00
brought muc invites back. + couple of bug fixes + refactoring
This commit is contained in:
parent
670dead695
commit
38a9242955
@ -49,7 +49,7 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name="eu.siacs.conversations.ui.StartConversation"
|
||||
android:name="eu.siacs.conversations.ui.StartConversationActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:label="@string/title_activity_start_conversation"
|
||||
android:logo="@drawable/ic_activity"
|
||||
@ -68,6 +68,9 @@
|
||||
android:label="@string/title_activity_settings"
|
||||
android:parentActivityName="eu.siacs.conversations.ui.ConversationActivity" >
|
||||
</activity>
|
||||
<activity android:name="eu.siacs.conversations.ui.ChooseContactActivity"
|
||||
android:label="@string/title_activity_choose_contact">
|
||||
</activity>
|
||||
<activity
|
||||
android:name="eu.siacs.conversations.ui.ManageAccountActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
@ -75,7 +78,7 @@
|
||||
android:parentActivityName="eu.siacs.conversations.ui.ConversationActivity" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name="eu.siacs.conversations.ui.MucDetailsActivity"
|
||||
android:name="eu.siacs.conversations.ui.ConferenceDetailsActivity"
|
||||
android:label="@string/title_activity_conference_details"
|
||||
android:windowSoftInputMode="stateHidden" >
|
||||
</activity>
|
||||
|
13
res/layout/activity_choose_contact.xml
Normal file
13
res/layout/activity_choose_contact.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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" >
|
||||
|
||||
<ListView
|
||||
android:id="@+id/choose_contact_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:listitem="@layout/contact" />
|
||||
|
||||
</LinearLayout>
|
@ -63,7 +63,6 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:text="hallo hallo"
|
||||
android:textColor="@color/primarytext"
|
||||
android:textSize="18sp" />
|
||||
|
||||
@ -72,7 +71,6 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:text="Participant"
|
||||
android:textColor="@color/primarytext"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
@ -123,7 +121,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="@string/invite_contacts" />
|
||||
android:text="@string/invite_contact" />
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
10
res/menu/choose_contact.xml
Normal file
10
res/menu/choose_contact.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<item
|
||||
android:id="@+id/action_search"
|
||||
android:actionLayout="@layout/actionview_search"
|
||||
android:icon="@drawable/ic_action_search"
|
||||
android:showAsAction="collapseActionView|always"
|
||||
android:title="@string/search"/>
|
||||
</menu>
|
@ -2,25 +2,22 @@
|
||||
|
||||
<item
|
||||
android:id="@+id/action_add"
|
||||
android:orderInCategory="10"
|
||||
android:icon="@drawable/ic_action_new"
|
||||
android:orderInCategory="10"
|
||||
android:showAsAction="always"
|
||||
android:title="@string/action_add"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_security"
|
||||
android:icon="@drawable/ic_action_not_secure"
|
||||
android:orderInCategory="20"
|
||||
android:showAsAction="always"
|
||||
android:icon="@drawable/ic_action_not_secure"
|
||||
android:title="@string/action_secure"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_attach_file"
|
||||
android:icon="@drawable/ic_action_new_attachment"
|
||||
android:orderInCategory="30"
|
||||
android:showAsAction="always"
|
||||
android:icon="@drawable/ic_action_new_attachment"
|
||||
android:title="@string/attach_file"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_contact_details"
|
||||
android:orderInCategory="40"
|
||||
@ -28,15 +25,15 @@
|
||||
android:title="@string/action_contact_details"/>
|
||||
<item
|
||||
android:id="@+id/action_muc_details"
|
||||
android:icon="@drawable/ic_action_group"
|
||||
android:orderInCategory="40"
|
||||
android:showAsAction="ifRoom"
|
||||
android:icon="@drawable/ic_action_group"
|
||||
android:title="@string/action_muc_details"/>
|
||||
<item
|
||||
android:id="@+id/action_invite"
|
||||
android:orderInCategory="45"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/invite_contacts" />
|
||||
|
||||
android:title="@string/invite_contact"/>
|
||||
<item
|
||||
android:id="@+id/action_archive"
|
||||
android:orderInCategory="50"
|
||||
@ -51,9 +48,7 @@
|
||||
android:id="@+id/action_accounts"
|
||||
android:orderInCategory="90"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/action_accounts"
|
||||
/>
|
||||
|
||||
android:title="@string/action_accounts"/>
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:orderInCategory="100"
|
||||
|
@ -47,10 +47,7 @@
|
||||
<string name="show_otr_key">OTR fingerprint</string>
|
||||
<string name="no_otr_fingerprint">No OTR Fingerprint generated. Just go ahead an start an encrypted conversation</string>
|
||||
<string name="start_conversation">Start Conversation</string>
|
||||
<string name="invite_contacts">Invite Contacts</string>
|
||||
<string name="invite_contacts_to_existing">Invite to existing conference</string>
|
||||
<string name="new_conference">Create new conference</string>
|
||||
<string name="new_contact">Create new contact</string>
|
||||
<string name="invite_contact">Invite Contact</string>
|
||||
<string name="contacts">Contacts</string>
|
||||
<string name="search_jabber_id">Search or enter Jabber ID</string>
|
||||
<string name="choose_account">Choose account</string>
|
||||
@ -272,4 +269,5 @@
|
||||
<string name="bookmark_already_exists">This bookmark already exists</string>
|
||||
<string name="you">You</string>
|
||||
<string name="action_edit_subject">Edit conference subject</string>
|
||||
<string name="title_activity_choose_contact">Choose contact</string>
|
||||
</resources>
|
||||
|
@ -220,11 +220,14 @@ public class MessageParser extends AbstractParser implements
|
||||
} else if (packet.hasChild("x")) {
|
||||
Element x = packet.findChild("x");
|
||||
if (x.hasChild("invite")) {
|
||||
mXmppConnectionService
|
||||
Conversation conversation = mXmppConnectionService
|
||||
.findOrCreateConversation(account,
|
||||
packet.getAttribute("from"), true);
|
||||
if (!conversation.getMucOptions().online()) {
|
||||
mXmppConnectionService.joinMuc(conversation);
|
||||
mXmppConnectionService.updateConversationUi();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1189,21 +1189,18 @@ public class XmppConnectionService extends Service {
|
||||
}).start();
|
||||
}
|
||||
|
||||
public void inviteToConference(Conversation conversation,
|
||||
List<Contact> contacts) {
|
||||
for (Contact contact : contacts) {
|
||||
public void inviteToConference(Conversation conversation, String contactJid) {
|
||||
Account account = conversation.getAccount();
|
||||
MessagePacket packet = new MessagePacket();
|
||||
packet.setTo(conversation.getContactJid().split("/")[0]);
|
||||
packet.setFrom(conversation.getAccount().getFullJid());
|
||||
packet.setFrom(account.getFullJid());
|
||||
Element x = new Element("x");
|
||||
x.setAttribute("xmlns", "http://jabber.org/protocol/muc#user");
|
||||
Element invite = new Element("invite");
|
||||
invite.setAttribute("to", contact.getJid());
|
||||
invite.setAttribute("to", contactJid);
|
||||
x.addChild(invite);
|
||||
packet.addChild(x);
|
||||
Log.d(LOGTAG, packet.toString());
|
||||
sendMessagePacket(conversation.getAccount(),packet);
|
||||
}
|
||||
sendMessagePacket(account,packet);
|
||||
|
||||
}
|
||||
|
||||
@ -1274,6 +1271,15 @@ public class XmppConnectionService extends Service {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Conversation findConversationByUuid(String uuid) {
|
||||
for (Conversation conversation : getConversations()) {
|
||||
if (conversation.getUuid().equals(uuid)) {
|
||||
return conversation;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void markRead(Conversation conversation) {
|
||||
conversation.markRead();
|
||||
String id = conversation.popLatestMarkableMessageId();
|
||||
|
140
src/eu/siacs/conversations/ui/ChooseContactActivity.java
Normal file
140
src/eu/siacs/conversations/ui/ChooseContactActivity.java
Normal file
@ -0,0 +1,140 @@
|
||||
package eu.siacs.conversations.ui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ListView;
|
||||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.entities.Account;
|
||||
import eu.siacs.conversations.entities.Contact;
|
||||
import eu.siacs.conversations.entities.ListItem;
|
||||
import eu.siacs.conversations.ui.adapter.ListItemAdapter;
|
||||
|
||||
public class ChooseContactActivity extends XmppActivity {
|
||||
|
||||
private ListView mListView;
|
||||
private ArrayList<ListItem> contacts = new ArrayList<ListItem>();
|
||||
private ArrayAdapter<ListItem> mContactsAdapter;
|
||||
|
||||
private EditText mSearchEditText;
|
||||
|
||||
private TextWatcher mSearchTextWatcher = new TextWatcher() {
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
filterContacts(editable.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count,
|
||||
int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before,
|
||||
int count) {
|
||||
}
|
||||
};
|
||||
|
||||
private MenuItem.OnActionExpandListener mOnActionExpandListener = new MenuItem.OnActionExpandListener() {
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemActionExpand(MenuItem item) {
|
||||
mSearchEditText.post(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
mSearchEditText.requestFocus();
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.showSoftInput(mSearchEditText,
|
||||
InputMethodManager.SHOW_IMPLICIT);
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemActionCollapse(MenuItem item) {
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(mSearchEditText.getWindowToken(),
|
||||
InputMethodManager.HIDE_IMPLICIT_ONLY);
|
||||
mSearchEditText.setText("");
|
||||
filterContacts(null);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_choose_contact);
|
||||
mListView = (ListView) findViewById(R.id.choose_contact_list);
|
||||
mContactsAdapter = new ListItemAdapter(getApplicationContext(), contacts);
|
||||
mListView.setAdapter(mContactsAdapter);
|
||||
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> arg0, View arg1, int position,
|
||||
long arg3) {
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(mSearchEditText.getWindowToken(),
|
||||
InputMethodManager.HIDE_IMPLICIT_ONLY);
|
||||
Intent request = getIntent();
|
||||
Intent data = new Intent();
|
||||
data.putExtra("contact",contacts.get(position).getJid());
|
||||
data.putExtra("account",request.getStringExtra("account"));
|
||||
data.putExtra("conversation",request.getStringExtra("conversation"));
|
||||
setResult(RESULT_OK, data);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.choose_contact, menu);
|
||||
MenuItem menuSearchView = (MenuItem) menu.findItem(R.id.action_search);
|
||||
View mSearchView = menuSearchView.getActionView();
|
||||
mSearchEditText = (EditText) mSearchView
|
||||
.findViewById(R.id.search_field);
|
||||
mSearchEditText.addTextChangedListener(mSearchTextWatcher);
|
||||
menuSearchView.setOnActionExpandListener(mOnActionExpandListener);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
void onBackendConnected() {
|
||||
filterContacts(null);
|
||||
}
|
||||
|
||||
protected void filterContacts(String needle) {
|
||||
this.contacts.clear();
|
||||
for (Account account : xmppConnectionService.getAccounts()) {
|
||||
if (account.getStatus() != Account.STATUS_DISABLED) {
|
||||
for (Contact contact : account.getRoster().getContacts()) {
|
||||
if (contact.showInRoster() && contact.match(needle)) {
|
||||
this.contacts.add(contact);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Collections.sort(this.contacts);
|
||||
mContactsAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
}
|
@ -31,7 +31,7 @@ import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class MucDetailsActivity extends XmppActivity {
|
||||
public class ConferenceDetailsActivity extends XmppActivity {
|
||||
public static final String ACTION_VIEW_MUC = "view_muc";
|
||||
private Conversation conversation;
|
||||
private TextView mYourNick;
|
||||
@ -48,12 +48,7 @@ public class MucDetailsActivity extends XmppActivity {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
/*
|
||||
* Intent intent = new Intent(getApplicationContext(),
|
||||
* ContactsActivity.class); intent.setAction("invite");
|
||||
* intent.putExtra("uuid",conversation.getUuid());
|
||||
* startActivity(intent);
|
||||
*/
|
||||
inviteToConversation(conversation);
|
||||
}
|
||||
};
|
||||
|
||||
@ -155,11 +150,7 @@ public class MucDetailsActivity extends XmppActivity {
|
||||
this.uuid = getIntent().getExtras().getString("uuid");
|
||||
}
|
||||
if (uuid != null) {
|
||||
for (Conversation mConv : xmppConnectionService.getConversations()) {
|
||||
if (mConv.getUuid().equals(uuid)) {
|
||||
this.conversation = mConv;
|
||||
}
|
||||
}
|
||||
this.conversation = xmppConnectionService.findConversationByUuid(uuid);
|
||||
if (this.conversation != null) {
|
||||
populateView();
|
||||
}
|
||||
@ -188,11 +179,11 @@ public class MucDetailsActivity extends XmppActivity {
|
||||
public void run() {
|
||||
populateView();
|
||||
if (success) {
|
||||
Toast.makeText(MucDetailsActivity.this,
|
||||
Toast.makeText(ConferenceDetailsActivity.this,
|
||||
getString(R.string.your_nick_has_been_changed),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Toast.makeText(MucDetailsActivity.this,
|
||||
Toast.makeText(ConferenceDetailsActivity.this,
|
||||
getString(R.string.nick_in_use),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
@ -21,7 +21,6 @@ import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.QuickContactBadge;
|
||||
import android.widget.TextView;
|
||||
@ -45,7 +44,6 @@ public class ContactDetailsActivity extends XmppActivity {
|
||||
private String accountJid;
|
||||
private String contactJid;
|
||||
|
||||
private EditText name;
|
||||
private TextView contactJidTv;
|
||||
private TextView accountJidTv;
|
||||
private TextView status;
|
||||
@ -63,16 +61,6 @@ public class ContactDetailsActivity extends XmppActivity {
|
||||
}
|
||||
};
|
||||
|
||||
private DialogInterface.OnClickListener editContactNameListener = new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
contact.setServerName(name.getText().toString());
|
||||
activity.xmppConnectionService.pushContactToServer(contact);
|
||||
populateView();
|
||||
}
|
||||
};
|
||||
|
||||
private DialogInterface.OnClickListener addToPhonebook = new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
|
@ -98,7 +98,7 @@ public class ConversationActivity extends XmppActivity {
|
||||
swapConversationFragment();
|
||||
} else {
|
||||
startActivity(new Intent(getApplicationContext(),
|
||||
StartConversation.class));
|
||||
StartConversationActivity.class));
|
||||
finish();
|
||||
}
|
||||
}
|
||||
@ -306,23 +306,26 @@ public class ConversationActivity extends XmppActivity {
|
||||
.findItem(R.id.action_muc_details);
|
||||
MenuItem menuContactDetails = (MenuItem) menu
|
||||
.findItem(R.id.action_contact_details);
|
||||
MenuItem menuInviteContacts = (MenuItem) menu
|
||||
.findItem(R.id.action_invite);
|
||||
MenuItem menuAttach = (MenuItem) menu.findItem(R.id.action_attach_file);
|
||||
MenuItem menuClearHistory = (MenuItem) menu
|
||||
.findItem(R.id.action_clear_history);
|
||||
MenuItem menuManageAccounts = (MenuItem) menu.findItem(R.id.action_accounts);
|
||||
MenuItem menuSettings = (MenuItem) menu.findItem(R.id.action_settings);
|
||||
MenuItem menuAdd = (MenuItem) menu.findItem(R.id.action_add);
|
||||
MenuItem menuInviteContact = (MenuItem) menu.findItem(R.id.action_invite);
|
||||
|
||||
if ((spl.isOpen() && (spl.isSlideable()))) {
|
||||
menuArchive.setVisible(false);
|
||||
menuMucDetails.setVisible(false);
|
||||
menuContactDetails.setVisible(false);
|
||||
menuSecure.setVisible(false);
|
||||
menuInviteContacts.setVisible(false);
|
||||
menuInviteContact.setVisible(false);
|
||||
menuAttach.setVisible(false);
|
||||
menuClearHistory.setVisible(false);
|
||||
} else {
|
||||
((MenuItem) menu.findItem(R.id.action_add)).setVisible(!spl
|
||||
.isSlideable());
|
||||
menuAdd.setVisible(!spl.isSlideable());
|
||||
menuSettings.setVisible(!spl.isSlideable());
|
||||
menuManageAccounts.setVisible(!spl.isSlideable());
|
||||
if (this.getSelectedConversation() != null) {
|
||||
if (this.getSelectedConversation().getLatestMessage()
|
||||
.getEncryption() != Message.ENCRYPTION_NONE) {
|
||||
@ -333,7 +336,7 @@ public class ConversationActivity extends XmppActivity {
|
||||
menuAttach.setVisible(false);
|
||||
} else {
|
||||
menuMucDetails.setVisible(false);
|
||||
menuInviteContacts.setVisible(false);
|
||||
menuInviteContact.setVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -458,7 +461,7 @@ public class ConversationActivity extends XmppActivity {
|
||||
attachFilePopup.show();
|
||||
break;
|
||||
case R.id.action_add:
|
||||
startActivity(new Intent(this, StartConversation.class));
|
||||
startActivity(new Intent(this, StartConversationActivity.class));
|
||||
break;
|
||||
case R.id.action_archive:
|
||||
this.endConversation(getSelectedConversation());
|
||||
@ -472,17 +475,13 @@ public class ConversationActivity extends XmppActivity {
|
||||
}
|
||||
break;
|
||||
case R.id.action_muc_details:
|
||||
Intent intent = new Intent(this, MucDetailsActivity.class);
|
||||
intent.setAction(MucDetailsActivity.ACTION_VIEW_MUC);
|
||||
Intent intent = new Intent(this, ConferenceDetailsActivity.class);
|
||||
intent.setAction(ConferenceDetailsActivity.ACTION_VIEW_MUC);
|
||||
intent.putExtra("uuid", getSelectedConversation().getUuid());
|
||||
startActivity(intent);
|
||||
break;
|
||||
case R.id.action_invite:
|
||||
/*Intent inviteIntent = new Intent(getApplicationContext(),
|
||||
ContactsActivity.class);
|
||||
inviteIntent.setAction("invite");
|
||||
inviteIntent.putExtra("uuid", getSelectedConversation().getUuid());
|
||||
startActivity(inviteIntent);*/
|
||||
inviteToConversation(getSelectedConversation());
|
||||
break;
|
||||
case R.id.action_security:
|
||||
final Conversation conversation = getSelectedConversation();
|
||||
@ -699,7 +698,7 @@ public class ConversationActivity extends XmppActivity {
|
||||
finish();
|
||||
} else if (conversationList.size() <= 0) {
|
||||
// add no history
|
||||
startActivity(new Intent(this, StartConversation.class));
|
||||
startActivity(new Intent(this, StartConversationActivity.class));
|
||||
finish();
|
||||
} else {
|
||||
spl.openPane();
|
||||
|
@ -12,9 +12,9 @@ import eu.siacs.conversations.entities.Contact;
|
||||
import eu.siacs.conversations.entities.Conversation;
|
||||
import eu.siacs.conversations.entities.Message;
|
||||
import eu.siacs.conversations.entities.MucOptions;
|
||||
import eu.siacs.conversations.entities.MucOptions.OnRenameListener;
|
||||
import eu.siacs.conversations.services.ImageProvider;
|
||||
import eu.siacs.conversations.services.XmppConnectionService;
|
||||
import eu.siacs.conversations.ui.XmppActivity.OnPresenceSelected;
|
||||
import eu.siacs.conversations.utils.UIHelper;
|
||||
import eu.siacs.conversations.xmpp.jingle.JingleConnection;
|
||||
import android.app.AlertDialog;
|
||||
@ -118,8 +118,8 @@ public class ConversationFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getActivity(), MucDetailsActivity.class);
|
||||
intent.setAction(MucDetailsActivity.ACTION_VIEW_MUC);
|
||||
Intent intent = new Intent(getActivity(), ConferenceDetailsActivity.class);
|
||||
intent.setAction(ConferenceDetailsActivity.ACTION_VIEW_MUC);
|
||||
intent.putExtra("uuid", conversation.getUuid());
|
||||
startActivity(intent);
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import java.util.List;
|
||||
|
||||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.entities.Account;
|
||||
import eu.siacs.conversations.utils.KnownHostsAdapter;
|
||||
import eu.siacs.conversations.ui.adapter.KnownHostsAdapter;
|
||||
import eu.siacs.conversations.utils.Validator;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
@ -21,7 +21,7 @@ import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class EditAccount extends DialogFragment {
|
||||
public class EditAccountDialog extends DialogFragment {
|
||||
|
||||
protected Account account;
|
||||
|
@ -6,7 +6,7 @@ import java.util.List;
|
||||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.entities.Account;
|
||||
import eu.siacs.conversations.services.XmppConnectionService.OnAccountUpdate;
|
||||
import eu.siacs.conversations.ui.EditAccount.EditAccountListener;
|
||||
import eu.siacs.conversations.ui.EditAccountDialog.EditAccountListener;
|
||||
import eu.siacs.conversations.xmpp.OnTLSExceptionReceived;
|
||||
import eu.siacs.conversations.xmpp.XmppConnection;
|
||||
import android.app.Activity;
|
||||
@ -221,7 +221,7 @@ public class ManageAccountActivity extends XmppActivity {
|
||||
} else if (account.getStatus() == Account.STATUS_ONLINE) {
|
||||
activity.startActivity(new Intent(activity
|
||||
.getApplicationContext(),
|
||||
StartConversation.class));
|
||||
StartConversationActivity.class));
|
||||
} else if (account.getStatus() != Account.STATUS_DISABLED) {
|
||||
editAccount(account);
|
||||
}
|
||||
@ -513,7 +513,7 @@ public class ManageAccountActivity extends XmppActivity {
|
||||
@Override
|
||||
public boolean onNavigateUp() {
|
||||
if (xmppConnectionService.getConversations().size() == 0) {
|
||||
Intent contactsIntent = new Intent(this, StartConversation.class);
|
||||
Intent contactsIntent = new Intent(this, StartConversationActivity.class);
|
||||
contactsIntent.setFlags(
|
||||
// if activity exists in stack, pop the stack and go back to it
|
||||
Intent.FLAG_ACTIVITY_CLEAR_TOP |
|
||||
@ -531,7 +531,7 @@ public class ManageAccountActivity extends XmppActivity {
|
||||
}
|
||||
|
||||
private void editAccount(Account account) {
|
||||
EditAccount dialog = new EditAccount();
|
||||
EditAccountDialog dialog = new EditAccountDialog();
|
||||
dialog.setAccount(account);
|
||||
dialog.setEditAccountListener(new EditAccountListener() {
|
||||
|
||||
@ -550,7 +550,7 @@ public class ManageAccountActivity extends XmppActivity {
|
||||
|
||||
protected void addAccount() {
|
||||
final Activity activity = this;
|
||||
EditAccount dialog = new EditAccount();
|
||||
EditAccountDialog dialog = new EditAccountDialog();
|
||||
dialog.setEditAccountListener(new EditAccountListener() {
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +0,0 @@
|
||||
package eu.siacs.conversations.ui;
|
||||
|
||||
public interface OnPresenceSelected {
|
||||
public void onPresenceSelected();
|
||||
}
|
@ -21,11 +21,9 @@ import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.AdapterContextMenuInfo;
|
||||
@ -34,20 +32,19 @@ import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.entities.Account;
|
||||
import eu.siacs.conversations.entities.Bookmark;
|
||||
import eu.siacs.conversations.entities.Contact;
|
||||
import eu.siacs.conversations.entities.Conversation;
|
||||
import eu.siacs.conversations.entities.ListItem;
|
||||
import eu.siacs.conversations.utils.KnownHostsAdapter;
|
||||
import eu.siacs.conversations.ui.adapter.KnownHostsAdapter;
|
||||
import eu.siacs.conversations.ui.adapter.ListItemAdapter;
|
||||
import eu.siacs.conversations.utils.Validator;
|
||||
|
||||
public class StartConversation extends XmppActivity {
|
||||
public class StartConversationActivity extends XmppActivity {
|
||||
|
||||
private Tab mContactsTab;
|
||||
private Tab mConferencesTab;
|
||||
@ -176,7 +173,7 @@ public class StartConversation extends XmppActivity {
|
||||
}
|
||||
});
|
||||
|
||||
mConferenceAdapter = new ListItemAdapter(conferences);
|
||||
mConferenceAdapter = new ListItemAdapter(getApplicationContext(),conferences);
|
||||
mConferenceListFragment.setListAdapter(mConferenceAdapter);
|
||||
mConferenceListFragment.setContextMenu(R.menu.conference_context);
|
||||
mConferenceListFragment
|
||||
@ -189,7 +186,7 @@ public class StartConversation extends XmppActivity {
|
||||
}
|
||||
});
|
||||
|
||||
mContactsAdapter = new ListItemAdapter(contacts);
|
||||
mContactsAdapter = new ListItemAdapter(getApplicationContext(),contacts);
|
||||
mContactsListFragment.setListAdapter(mContactsAdapter);
|
||||
mContactsListFragment.setContextMenu(R.menu.contact_context);
|
||||
mContactsListFragment
|
||||
@ -502,33 +499,6 @@ public class StartConversation extends XmppActivity {
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
private class ListItemAdapter extends ArrayAdapter<ListItem> {
|
||||
|
||||
public ListItemAdapter(List<ListItem> objects) {
|
||||
super(getApplicationContext(), 0, objects);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View view, ViewGroup parent) {
|
||||
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
ListItem item = getItem(position);
|
||||
if (view == null) {
|
||||
view = (View) inflater.inflate(R.layout.contact, null);
|
||||
}
|
||||
TextView name = (TextView) view
|
||||
.findViewById(R.id.contact_display_name);
|
||||
TextView jid = (TextView) view.findViewById(R.id.contact_jid);
|
||||
ImageView picture = (ImageView) view
|
||||
.findViewById(R.id.contact_photo);
|
||||
|
||||
jid.setText(item.getJid());
|
||||
name.setText(item.getDisplayName());
|
||||
picture.setImageBitmap(item.getImage(48, getApplicationContext()));
|
||||
return view;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class MyListFragment extends ListFragment {
|
||||
private AdapterView.OnItemClickListener mOnItemClickListener;
|
||||
private int mResContextMenu;
|
||||
@ -558,7 +528,7 @@ public class StartConversation extends XmppActivity {
|
||||
public void onCreateContextMenu(ContextMenu menu, View v,
|
||||
ContextMenuInfo menuInfo) {
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
StartConversation activity = (StartConversation) getActivity();
|
||||
StartConversationActivity activity = (StartConversationActivity) getActivity();
|
||||
activity.getMenuInflater().inflate(mResContextMenu, menu);
|
||||
AdapterView.AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) menuInfo;
|
||||
if (mResContextMenu == R.menu.conference_context) {
|
||||
@ -570,7 +540,7 @@ public class StartConversation extends XmppActivity {
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
StartConversation activity = (StartConversation) getActivity();
|
||||
StartConversationActivity activity = (StartConversationActivity) getActivity();
|
||||
switch (item.getItemId()) {
|
||||
case R.id.context_start_conversation:
|
||||
activity.openConversationForContact();
|
@ -23,6 +23,7 @@ import android.content.ServiceConnection;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
@ -31,6 +32,7 @@ import android.widget.EditText;
|
||||
public abstract class XmppActivity extends Activity {
|
||||
|
||||
public static final int REQUEST_ANNOUNCE_PGP = 0x73731;
|
||||
protected static final int REQUEST_INVITE_TO_CONVERSATION = 0x341830;
|
||||
|
||||
protected final static String LOGTAG = "xmppService";
|
||||
|
||||
@ -42,6 +44,10 @@ public abstract class XmppActivity extends Activity {
|
||||
public void onValueEdited(String value);
|
||||
}
|
||||
|
||||
public interface OnPresenceSelected {
|
||||
public void onPresenceSelected();
|
||||
}
|
||||
|
||||
protected ServiceConnection mConnection = new ServiceConnection() {
|
||||
|
||||
@Override
|
||||
@ -187,6 +193,12 @@ public abstract class XmppActivity extends Activity {
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
protected void inviteToConversation(Conversation conversation) {
|
||||
Intent intent = new Intent(getApplicationContext(), ChooseContactActivity.class);
|
||||
intent.putExtra("conversation",conversation.getUuid());
|
||||
startActivityForResult(intent, REQUEST_INVITE_TO_CONVERSATION);
|
||||
}
|
||||
|
||||
protected void announcePgp(Account account, final Conversation conversation) {
|
||||
xmppConnectionService.getPgpEngine().generateSignature(account,
|
||||
"online", new UiCallback<Account>() {
|
||||
@ -328,4 +340,18 @@ public abstract class XmppActivity extends Activity {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void onActivityResult(int requestCode, int resultCode,
|
||||
final Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == REQUEST_INVITE_TO_CONVERSATION && resultCode == RESULT_OK) {
|
||||
String contactJid = data.getStringExtra("contact");
|
||||
String conversationUuid = data.getStringExtra("conversation");
|
||||
Conversation conversation = xmppConnectionService.findConversationByUuid(conversationUuid);
|
||||
if (conversation.getMode() == Conversation.MODE_MULTI) {
|
||||
xmppConnectionService.inviteToConference(conversation, contactJid);
|
||||
}
|
||||
Log.d("xmppService","inviting "+contactJid+" to "+conversation.getName(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package eu.siacs.conversations.utils;
|
||||
package eu.siacs.conversations.ui.adapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -42,7 +42,7 @@ public class KnownHostsAdapter extends ArrayAdapter<String> {
|
||||
@Override
|
||||
protected void publishResults(CharSequence constraint,
|
||||
FilterResults results) {
|
||||
ArrayList<String> filteredList = ((ArrayList<String>) results.values);
|
||||
ArrayList<String> filteredList = (ArrayList<String>) results.values;
|
||||
if (results != null && results.count > 0) {
|
||||
clear();
|
||||
for (String c : filteredList) {
|
39
src/eu/siacs/conversations/ui/adapter/ListItemAdapter.java
Normal file
39
src/eu/siacs/conversations/ui/adapter/ListItemAdapter.java
Normal file
@ -0,0 +1,39 @@
|
||||
package eu.siacs.conversations.ui.adapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.entities.ListItem;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class ListItemAdapter extends ArrayAdapter<ListItem> {
|
||||
|
||||
public ListItemAdapter(Context context, List<ListItem> objects) {
|
||||
super(context, 0, objects);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View view, ViewGroup parent) {
|
||||
LayoutInflater inflater = (LayoutInflater) getContext()
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
ListItem item = getItem(position);
|
||||
if (view == null) {
|
||||
view = (View) inflater.inflate(R.layout.contact, null);
|
||||
}
|
||||
TextView name = (TextView) view.findViewById(R.id.contact_display_name);
|
||||
TextView jid = (TextView) view.findViewById(R.id.contact_jid);
|
||||
ImageView picture = (ImageView) view.findViewById(R.id.contact_photo);
|
||||
|
||||
jid.setText(item.getJid());
|
||||
name.setText(item.getDisplayName());
|
||||
picture.setImageBitmap(item.getImage(48, getContext()));
|
||||
return view;
|
||||
}
|
||||
|
||||
}
|
@ -13,7 +13,6 @@ 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.entities.ListItem;
|
||||
import eu.siacs.conversations.entities.Message;
|
||||
import eu.siacs.conversations.entities.MucOptions.User;
|
||||
import eu.siacs.conversations.ui.ConversationActivity;
|
||||
|
Loading…
Reference in New Issue
Block a user