aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2014-03-13 21:37:27 +0100
committerDaniel Gultsch <daniel@gultsch.de>2014-03-13 21:37:27 +0100
commit9c811f8fb20b056ea12803e93e5ea20dc052bdcd (patch)
tree7c4be8327ca3722f41d7784c126081a92585c26c /src/eu
parent507cfba6ad481b078528ead056088e6aa6c4a3fc (diff)
sharing text
Diffstat (limited to 'src/eu')
-rw-r--r--src/eu/siacs/conversations/services/XmppConnectionService.java12
-rw-r--r--src/eu/siacs/conversations/ui/ConversationActivity.java5
-rw-r--r--src/eu/siacs/conversations/ui/ConversationFragment.java14
-rw-r--r--src/eu/siacs/conversations/ui/ManageAccountActivity.java16
-rw-r--r--src/eu/siacs/conversations/ui/MucDetailsActivity.java20
-rw-r--r--src/eu/siacs/conversations/ui/NewConversationActivity.java43
-rw-r--r--src/eu/siacs/conversations/ui/ShareWithActivity.java128
-rw-r--r--src/eu/siacs/conversations/ui/XmppActivity.java16
-rw-r--r--src/eu/siacs/conversations/xmpp/XmppConnection.java2
9 files changed, 189 insertions, 67 deletions
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index 57cb60b9..9a5cbc0c 100644
--- a/src/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/eu/siacs/conversations/services/XmppConnectionService.java
@@ -398,7 +398,7 @@ public class XmppConnectionService extends Service {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
- Log.d(LOGTAG,"calling start service. caller was:"+intent.getAction());
+ //Log.d(LOGTAG,"calling start service. caller was:"+intent.getAction());
ConnectivityManager cm = (ConnectivityManager) getApplicationContext()
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
@@ -670,7 +670,7 @@ public class XmppConnectionService extends Service {
return packet;
}
- public void getRoster(Account account,
+ private void getRoster(Account account,
final OnRosterFetchedListener listener) {
List<Contact> contacts = databaseBackend.getContactsByAccount(account);
for (int i = 0; i < contacts.size(); ++i) {
@@ -680,6 +680,14 @@ public class XmppConnectionService extends Service {
listener.onRosterFetched(contacts);
}
}
+
+ public List<Contact> getRoster(Account account) {
+ List<Contact> contacts = databaseBackend.getContactsByAccount(account);
+ for (int i = 0; i < contacts.size(); ++i) {
+ contacts.get(i).setAccount(account);
+ }
+ return contacts;
+ }
public void updateRoster(final Account account,
final OnRosterFetchedListener listener) {
diff --git a/src/eu/siacs/conversations/ui/ConversationActivity.java b/src/eu/siacs/conversations/ui/ConversationActivity.java
index e471d46d..1577fdc5 100644
--- a/src/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/eu/siacs/conversations/ui/ConversationActivity.java
@@ -11,7 +11,6 @@ import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.utils.UIHelper;
-import android.net.Uri;
import android.os.Bundle;
import android.app.AlertDialog;
import android.app.FragmentTransaction;
@@ -42,6 +41,7 @@ public class ConversationActivity extends XmppActivity {
public static final String VIEW_CONVERSATION = "viewConversation";
public static final String CONVERSATION = "conversationUuid";
+ public static final String TEXT = "text";
public static final int REQUEST_SEND_MESSAGE = 0x75441;
public static final int REQUEST_DECRYPT_PGP = 0x76783;
@@ -437,7 +437,8 @@ public class ConversationActivity extends XmppActivity {
}
}
paneShouldBeOpen = false;
- swapConversationFragment();
+ String text = getIntent().getExtras().getString(TEXT, null);
+ swapConversationFragment().setText(text);
}
} else {
if (xmppConnectionService.getAccounts().size() == 0) {
diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java
index 2aabec87..23b17077 100644
--- a/src/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/eu/siacs/conversations/ui/ConversationFragment.java
@@ -1,6 +1,5 @@
package eu.siacs.conversations.ui;
-import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
@@ -19,7 +18,6 @@ import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.entities.MucOptions;
import eu.siacs.conversations.entities.MucOptions.OnRenameListener;
import eu.siacs.conversations.services.XmppConnectionService;
-import eu.siacs.conversations.utils.PhoneHelper;
import eu.siacs.conversations.utils.UIHelper;
import android.app.AlertDialog;
import android.app.Fragment;
@@ -30,9 +28,7 @@ import android.content.IntentSender;
import android.content.SharedPreferences;
import android.content.IntentSender.SendIntentException;
import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
import android.graphics.Typeface;
-import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
@@ -63,6 +59,7 @@ public class ConversationFragment extends Fragment {
protected String queuedPqpMessage = null;
private EditText chatMsg;
+ private String pastedText = null;
protected Bitmap selfBitmap;
@@ -153,6 +150,11 @@ public class ConversationFragment extends Fragment {
final View view = inflater.inflate(R.layout.fragment_conversation,
container, false);
chatMsg = (EditText) view.findViewById(R.id.textinput);
+
+ if (pastedText!=null) {
+ chatMsg.setText(pastedText);
+ }
+
ImageButton sendButton = (ImageButton) view
.findViewById(R.id.textSendButton);
sendButton.setOnClickListener(this.sendMsgListener);
@@ -640,4 +642,8 @@ public class ConversationFragment extends Fragment {
}
}
+
+ public void setText(String text) {
+ this.pastedText = text;
+ }
}
diff --git a/src/eu/siacs/conversations/ui/ManageAccountActivity.java b/src/eu/siacs/conversations/ui/ManageAccountActivity.java
index 0d3adc85..22f7c78f 100644
--- a/src/eu/siacs/conversations/ui/ManageAccountActivity.java
+++ b/src/eu/siacs/conversations/ui/ManageAccountActivity.java
@@ -289,6 +289,8 @@ public class ManageAccountActivity extends XmppActivity {
XmppConnection xmpp = selectedAccountForActionMode.getXmppConnection();
long connectionAge = (SystemClock.elapsedRealtime() - xmpp.lastConnect) / 60000;
long sessionAge = (SystemClock.elapsedRealtime() - xmpp.lastSessionStarted) / 60000;
+ long connectionAgeHours = connectionAge / 60;
+ long sessionAgeHours = sessionAge / 60;
View view = (View) getLayoutInflater().inflate(R.layout.server_info, null);
TextView connection = (TextView) view.findViewById(R.id.connection);
TextView session = (TextView) view.findViewById(R.id.session);
@@ -299,13 +301,21 @@ public class ManageAccountActivity extends XmppActivity {
TextView roster = (TextView) view.findViewById(R.id.roster);
pcks_received.setText(""+xmpp.getReceivedStanzas());
pcks_sent.setText(""+xmpp.getSentStanzas());
- connection.setText(connectionAge+" mins");
+ if (connectionAgeHours >= 2) {
+ connection.setText(connectionAgeHours+" hours");
+ } else {
+ connection.setText(connectionAge+" mins");
+ }
if (xmpp.hasFeatureStreamManagment()) {
- session.setText(sessionAge+" mins");
+ if (sessionAgeHours >= 2) {
+ session.setText(sessionAgeHours+" hours");
+ } else {
+ session.setText(sessionAge+" mins");
+ }
stream.setText("Yes");
} else {
stream.setText("No");
- session.setText(connectionAge+" mins");
+ session.setText(connection.getText());
}
if (xmpp.hasFeaturesCarbon()) {
carbon.setText("Yes");
diff --git a/src/eu/siacs/conversations/ui/MucDetailsActivity.java b/src/eu/siacs/conversations/ui/MucDetailsActivity.java
index 5bd3556c..478397e7 100644
--- a/src/eu/siacs/conversations/ui/MucDetailsActivity.java
+++ b/src/eu/siacs/conversations/ui/MucDetailsActivity.java
@@ -64,26 +64,6 @@ public class MucDetailsActivity extends XmppActivity {
membersView = (LinearLayout) findViewById(R.id.muc_members);
mMoreDetails = (LinearLayout) findViewById(R.id.muc_more_details);
mMoreDetails.setVisibility(View.GONE);
- /*contactsAdapter = new ArrayAdapter<MucOptions.User>(this,
- R.layout.contact, users) {
- @Override
- public View getView(int position, View view, ViewGroup parent) {
- LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- User 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).getName());
- TextView role = (TextView) view.findViewById(R.id.contact_jid);
- role.setText(getReadableRole(contact.getRole()));
- ImageView imageView = (ImageView) view
- .findViewById(R.id.contact_photo);
- imageView.setImageBitmap(UIHelper.getContactPictureByName(contact.getName(), 90));
- return view;
- }
- };*/
getActionBar().setHomeButtonEnabled(true);
getActionBar().setDisplayHomeAsUpEnabled(true);
diff --git a/src/eu/siacs/conversations/ui/NewConversationActivity.java b/src/eu/siacs/conversations/ui/NewConversationActivity.java
index e275cea7..537e6c51 100644
--- a/src/eu/siacs/conversations/ui/NewConversationActivity.java
+++ b/src/eu/siacs/conversations/ui/NewConversationActivity.java
@@ -6,7 +6,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
-import java.util.Locale;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account;
@@ -14,11 +13,9 @@ import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.utils.UIHelper;
import eu.siacs.conversations.utils.Validator;
-import android.net.Uri;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
@@ -230,19 +227,7 @@ public class NewConversationActivity extends XmppActivity {
Conversation conversation = xmppConnectionService
.findOrCreateConversation(account, contact.getJid(), muc);
- switchToConversation(conversation);
- }
-
- public void switchToConversation(Conversation conversation) {
- Intent viewConversationIntent = new Intent(this,
- ConversationActivity.class);
- viewConversationIntent.setAction(Intent.ACTION_VIEW);
- viewConversationIntent.putExtra(ConversationActivity.CONVERSATION,
- conversation.getUuid());
- viewConversationIntent.setType(ConversationActivity.VIEW_CONVERSATION);
- viewConversationIntent.setFlags(viewConversationIntent.getFlags()
- | Intent.FLAG_ACTIVITY_CLEAR_TOP);
- startActivity(viewConversationIntent);
+ switchToConversation(conversation,null);
}
@Override
@@ -265,12 +250,14 @@ public class NewConversationActivity extends XmppActivity {
@Override
public void onClick(DialogInterface dialog, int which) {
Conversation conversation = xmppConnectionService.findOrCreateConversation(accounts.get(which), finalJid, false);
- switchToConversation(conversation);
+ switchToConversation(conversation,null);
+ finish();
}
}).show();
} else {
Conversation conversation = xmppConnectionService.findOrCreateConversation(this.accounts.get(0), jid, false);
- switchToConversation(conversation);
+ switchToConversation(conversation,null);
+ finish();
}
}
}
@@ -282,24 +269,10 @@ public class NewConversationActivity extends XmppActivity {
}
this.rosterContacts.clear();
for (int i = 0; i < accounts.size(); ++i) {
- xmppConnectionService.getRoster(accounts.get(i),
- new OnRosterFetchedListener() {
-
- @Override
- public void onRosterFetched(List<Contact> roster) {
- rosterContacts.addAll(roster);
- runOnUiThread(new Runnable() {
-
- @Override
- public void run() {
- updateAggregatedContacts();
- }
- });
-
- }
- });
- }
+ rosterContacts.addAll(xmppConnectionService.getRoster(accounts.get(i)));
}
+ updateAggregatedContacts();
+ }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
diff --git a/src/eu/siacs/conversations/ui/ShareWithActivity.java b/src/eu/siacs/conversations/ui/ShareWithActivity.java
new file mode 100644
index 00000000..81616212
--- /dev/null
+++ b/src/eu/siacs/conversations/ui/ShareWithActivity.java
@@ -0,0 +1,128 @@
+package eu.siacs.conversations.ui;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+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.UIHelper;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+public class ShareWithActivity extends XmppActivity {
+
+ private LinearLayout conversations;
+ private LinearLayout contacts;
+
+ private OnClickListener click = new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ // TODO Auto-generated method stub
+
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.share_with);
+ setTitle("Share with Conversation");
+
+ contacts = (LinearLayout) findViewById(R.id.contacts);
+ conversations = (LinearLayout) findViewById(R.id.conversations);
+
+ }
+
+
+ public View createContactView(String name, String msgTxt, Bitmap bm) {
+ View view = (View) getLayoutInflater().inflate(R.layout.contact, null);
+ view.setBackgroundResource(R.drawable.greybackground);
+ TextView contactName =(TextView) view.findViewById(R.id.contact_display_name);
+ contactName.setText(name);
+ TextView msg = (TextView) view.findViewById(R.id.contact_jid);
+ msg.setText(msgTxt);
+ ImageView imageView = (ImageView) view.findViewById(R.id.contact_photo);
+ imageView.setImageBitmap(bm);
+ return view;
+ }
+
+
+
+ @Override
+ void onBackendConnected() {
+ Set<String> displayedContacts = new HashSet<String>();
+ conversations.removeAllViews();
+ List<Conversation> convList = xmppConnectionService.getConversations();
+ Collections.sort(convList, new Comparator<Conversation>() {
+ @Override
+ public int compare(Conversation lhs, Conversation rhs) {
+ return (int) (rhs.getLatestMessage().getTimeSent() - lhs.getLatestMessage().getTimeSent());
+ }
+ });
+ for(final Conversation conversation : convList) {
+ View view = createContactView(conversation.getName(), conversation.getLatestMessage().getBody().trim(), UIHelper.getContactPicture(conversation.getContact(),conversation.getName(), 90,this.getApplicationContext()));
+ view.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ String sharedText = getIntent().getStringExtra(Intent.EXTRA_TEXT);
+ switchToConversation(conversation, sharedText);
+ finish();
+ }
+ });
+ conversations.addView(view);
+ if (conversation.getContact() != null) {
+ displayedContacts.add(conversation.getContact().getUuid());
+ }
+ }
+ contacts.removeAllViews();
+ final List<Contact> contactsList = new ArrayList<Contact>();
+ for(Account account : xmppConnectionService.getAccounts()) {
+ for(final Contact contact : xmppConnectionService.getRoster(account)) {
+ if (!displayedContacts.contains(contact.getUuid())) {
+ contactsList.add(contact);
+ }
+ }
+ }
+
+ Collections.sort(contactsList, new Comparator<Contact>() {
+ @Override
+ public int compare(Contact lhs, Contact rhs) {
+ return lhs.getDisplayName().compareToIgnoreCase(rhs.getDisplayName());
+ }
+ });
+
+ for(int i = 0; i < contactsList.size(); ++i) {
+ final Contact con = contactsList.get(i);
+ View view = createContactView(con.getDisplayName(), con.getJid(), UIHelper.getContactPicture(con,null, 90,this.getApplicationContext()));
+ view.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ String sharedText = getIntent().getStringExtra(Intent.EXTRA_TEXT);
+ Conversation conversation = xmppConnectionService.findOrCreateConversation(con.getAccount(), con.getJid(), false);
+ switchToConversation(conversation, sharedText);
+ finish();
+ }
+ });
+ contacts.addView(view);
+ }
+ }
+
+}
diff --git a/src/eu/siacs/conversations/ui/XmppActivity.java b/src/eu/siacs/conversations/ui/XmppActivity.java
index 1596a53a..dc8c3d5d 100644
--- a/src/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/eu/siacs/conversations/ui/XmppActivity.java
@@ -1,6 +1,7 @@
package eu.siacs.conversations.ui;
import eu.siacs.conversations.R;
+import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.services.XmppConnectionService.XmppConnectionBinder;
import eu.siacs.conversations.utils.ExceptionHelper;
@@ -103,4 +104,19 @@ public abstract class XmppActivity extends Activity {
super.onCreate(savedInstanceState);
ExceptionHelper.init(getApplicationContext());
}
+
+ public void switchToConversation(Conversation conversation, String text) {
+ Intent viewConversationIntent = new Intent(this,
+ ConversationActivity.class);
+ viewConversationIntent.setAction(Intent.ACTION_VIEW);
+ viewConversationIntent.putExtra(ConversationActivity.CONVERSATION,
+ conversation.getUuid());
+ if (text!=null) {
+ viewConversationIntent.putExtra(ConversationActivity.TEXT, text);
+ }
+ viewConversationIntent.setType(ConversationActivity.VIEW_CONVERSATION);
+ viewConversationIntent.setFlags(viewConversationIntent.getFlags()
+ | Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ startActivity(viewConversationIntent);
+ }
}
diff --git a/src/eu/siacs/conversations/xmpp/XmppConnection.java b/src/eu/siacs/conversations/xmpp/XmppConnection.java
index 5a29ad62..677c0ba6 100644
--- a/src/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -720,7 +720,7 @@ public class XmppConnection implements Runnable {
if (this.streamFeatures==null) {
return false;
} else {
- return this.streamFeatures.hasChild("has");
+ return this.streamFeatures.hasChild("sm");
}
}