aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/eu/siacs')
-rw-r--r--src/main/java/eu/siacs/conversations/Config.java3
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Bookmark.java5
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Message.java2
-rw-r--r--src/main/java/eu/siacs/conversations/entities/MucOptions.java10
-rw-r--r--src/main/java/eu/siacs/conversations/parser/PresenceParser.java2
-rw-r--r--src/main/java/eu/siacs/conversations/services/AvatarService.java13
-rw-r--r--src/main/java/eu/siacs/conversations/services/XmppConnectionService.java59
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ChooseContactActivity.java23
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java13
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationActivity.java2
-rw-r--r--src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java118
-rw-r--r--src/main/java/eu/siacs/conversations/ui/XmppActivity.java23
-rw-r--r--src/main/java/eu/siacs/conversations/utils/CryptoHelper.java11
-rw-r--r--src/main/java/eu/siacs/conversations/utils/ExceptionHelper.java26
14 files changed, 265 insertions, 45 deletions
diff --git a/src/main/java/eu/siacs/conversations/Config.java b/src/main/java/eu/siacs/conversations/Config.java
index 476e2ead..c73da59e 100644
--- a/src/main/java/eu/siacs/conversations/Config.java
+++ b/src/main/java/eu/siacs/conversations/Config.java
@@ -36,6 +36,8 @@ public final class Config {
public static final String LOGTAG = "conversations";
+ public static final String BUG_REPORTS = "bugs@conversations.im";
+
public static final String DOMAIN_LOCK = null; //only allow account creation for this domain
public static final String MAGIC_CREATE_DOMAIN = "conversations.im";
@@ -48,6 +50,7 @@ public final class Config {
public static final boolean SHOW_DISABLE_FOREGROUND = true; //if set to true the foreground notification has a button to disable it
public static final int PING_MAX_INTERVAL = 300;
+ public static final int IDLE_PING_INTERVAL = 600; //540 is minimum according to docs;
public static final int PING_MIN_INTERVAL = 30;
public static final int PING_TIMEOUT = 15;
public static final int SOCKET_TIMEOUT = 15;
diff --git a/src/main/java/eu/siacs/conversations/entities/Bookmark.java b/src/main/java/eu/siacs/conversations/entities/Bookmark.java
index fd6a5dab..c5c4ff5d 100644
--- a/src/main/java/eu/siacs/conversations/entities/Bookmark.java
+++ b/src/main/java/eu/siacs/conversations/entities/Bookmark.java
@@ -50,9 +50,8 @@ public class Bookmark extends Element implements ListItem {
@Override
public String getDisplayName() {
- if (this.mJoinedConversation != null
- && (this.mJoinedConversation.getMucOptions().getSubject() != null)) {
- return this.mJoinedConversation.getMucOptions().getSubject();
+ if (this.mJoinedConversation != null) {
+ return this.mJoinedConversation.getName();
} else if (getBookmarkName() != null) {
return getBookmarkName();
} else {
diff --git a/src/main/java/eu/siacs/conversations/entities/Message.java b/src/main/java/eu/siacs/conversations/entities/Message.java
index 818ac1d6..4b687711 100644
--- a/src/main/java/eu/siacs/conversations/entities/Message.java
+++ b/src/main/java/eu/siacs/conversations/entities/Message.java
@@ -19,7 +19,7 @@ public class Message extends AbstractEntity {
public static final String TABLENAME = "messages";
- public static final String MERGE_SEPARATOR = " \u200B\n\n";
+ public static final String MERGE_SEPARATOR = "\n\u0004\n";
public static final int STATUS_RECEIVED = 0;
public static final int STATUS_UNSEND = 1;
diff --git a/src/main/java/eu/siacs/conversations/entities/MucOptions.java b/src/main/java/eu/siacs/conversations/entities/MucOptions.java
index 68c1fb50..d0848370 100644
--- a/src/main/java/eu/siacs/conversations/entities/MucOptions.java
+++ b/src/main/java/eu/siacs/conversations/entities/MucOptions.java
@@ -18,6 +18,8 @@ import eu.siacs.conversations.xmpp.pep.Avatar;
@SuppressLint("DefaultLocale")
public class MucOptions {
+ private boolean mAutoPushConfiguration = true;
+
public Account getAccount() {
return this.conversation.getAccount();
}
@@ -39,6 +41,14 @@ public class MucOptions {
}
}
+ public void flagNoAutoPushConfiguration() {
+ mAutoPushConfiguration = false;
+ }
+
+ public boolean autoPushConfiguration() {
+ return mAutoPushConfiguration;
+ }
+
public enum Affiliation {
OWNER("owner", 4, R.string.owner),
ADMIN("admin", 3, R.string.admin),
diff --git a/src/main/java/eu/siacs/conversations/parser/PresenceParser.java b/src/main/java/eu/siacs/conversations/parser/PresenceParser.java
index edcd986e..b5718b61 100644
--- a/src/main/java/eu/siacs/conversations/parser/PresenceParser.java
+++ b/src/main/java/eu/siacs/conversations/parser/PresenceParser.java
@@ -78,7 +78,7 @@ public class PresenceParser extends AbstractParser implements
} else {
mucOptions.addUser(user);
}
- if (codes.contains(MucOptions.STATUS_CODE_ROOM_CREATED)) {
+ if (codes.contains(MucOptions.STATUS_CODE_ROOM_CREATED) && mucOptions.autoPushConfiguration()) {
Log.d(Config.LOGTAG,mucOptions.getAccount().getJid().toBareJid()
+": room '"
+mucOptions.getConversation().getJid().toBareJid()
diff --git a/src/main/java/eu/siacs/conversations/services/AvatarService.java b/src/main/java/eu/siacs/conversations/services/AvatarService.java
index 633758a5..9e8e6970 100644
--- a/src/main/java/eu/siacs/conversations/services/AvatarService.java
+++ b/src/main/java/eu/siacs/conversations/services/AvatarService.java
@@ -64,7 +64,7 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded {
public Bitmap get(final MucOptions.User user, final int size, boolean cachedOnly) {
Contact c = user.getContact();
- if (c != null && (c.getProfilePhoto() != null || c.getAvatar() != null)) {
+ if (c != null && (c.getProfilePhoto() != null || c.getAvatar() != null || user.getAvatar() == null)) {
return get(c, size, cachedOnly);
} else {
return getImpl(user, size, cachedOnly);
@@ -370,7 +370,7 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded {
private boolean drawTile(Canvas canvas, String name, int left, int top, int right, int bottom) {
if (name != null) {
- final String letter = name.isEmpty() ? "X" : name.substring(0, 1);
+ final String letter = getFirstLetter(name);
final int color = UIHelper.getColorForName(name);
drawTile(canvas, letter, color, left, top, right, bottom);
return true;
@@ -378,6 +378,15 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded {
return false;
}
+ private static String getFirstLetter(String name) {
+ for(Character c : name.toCharArray()) {
+ if (Character.isLetterOrDigit(c)) {
+ return c.toString();
+ }
+ }
+ return "X";
+ }
+
private boolean drawTile(Canvas canvas, Uri uri, int left, int top, int right, int bottom) {
if (uri != null) {
Bitmap bitmap = mXmppConnectionService.getFileBackend()
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
index 52a2fc22..7eebe069 100644
--- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
@@ -1,6 +1,7 @@
package eu.siacs.conversations.services;
import android.annotation.SuppressLint;
+import android.annotation.TargetApi;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.app.Service;
@@ -128,6 +129,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
public static final String ACTION_DISABLE_FOREGROUND = "disable_foreground";
public static final String ACTION_TRY_AGAIN = "try_again";
public static final String ACTION_DISABLE_ACCOUNT = "disable_account";
+ public static final String ACTION_IDLE_PING = "idle_ping";
private static final String ACTION_MERGE_PHONE_CONTACTS = "merge_phone_contacts";
public static final String ACTION_GCM_TOKEN_REFRESH = "gcm_token_refresh";
public static final String ACTION_GCM_MESSAGE_RECEIVED = "gcm_message_received";
@@ -551,8 +553,14 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
case ACTION_GCM_TOKEN_REFRESH:
refreshAllGcmTokens();
break;
+ case ACTION_IDLE_PING:
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ scheduleNextIdlePing();
+ }
+ break;
case ACTION_GCM_MESSAGE_RECEIVED:
Log.d(Config.LOGTAG,"gcm push message arrived in service. extras="+intent.getExtras());
+ break;
}
}
this.wakeLock.acquire();
@@ -627,7 +635,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
if (pingNow) {
for (Account account : pingCandidates) {
account.getXmppConnection().sendPing();
- Log.d(Config.LOGTAG, account.getJid().toBareJid() + " send ping");
+ Log.d(Config.LOGTAG, account.getJid().toBareJid() + " send ping (action="+action+")");
this.scheduleWakeUpCall(Config.PING_TIMEOUT, account.getUuid().hashCode());
}
}
@@ -759,6 +767,9 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
toggleForegroundService();
updateUnreadCountBadge();
toggleScreenEventReceiver();
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ scheduleNextIdlePing();
+ }
}
@Override
@@ -841,16 +852,25 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
public void scheduleWakeUpCall(int seconds, int requestCode) {
final long timeToWake = SystemClock.elapsedRealtime() + (seconds < 0 ? 1 : seconds + 1) * 1000;
-
- Context context = getApplicationContext();
- AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
-
- Intent intent = new Intent(context, EventReceiver.class);
+ AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
+ Intent intent = new Intent(this, EventReceiver.class);
intent.setAction("ping");
- PendingIntent alarmIntent = PendingIntent.getBroadcast(context, requestCode, intent, 0);
+ PendingIntent alarmIntent = PendingIntent.getBroadcast(this, requestCode, intent, 0);
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, timeToWake, alarmIntent);
}
+ @TargetApi(Build.VERSION_CODES.M)
+ private void scheduleNextIdlePing() {
+ Log.d(Config.LOGTAG,"schedule next idle ping");
+ AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
+ Intent intent = new Intent(this, EventReceiver.class);
+ intent.setAction(ACTION_IDLE_PING);
+ alarmManager.setAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP,
+ SystemClock.elapsedRealtime()+(Config.IDLE_PING_INTERVAL * 1000),
+ PendingIntent.getBroadcast(this,0,intent,0)
+ );
+ }
+
public XmppConnection createConnection(final Account account) {
final SharedPreferences sharedPref = getPreferences();
account.setResource(sharedPref.getString("resource", getString(R.string.default_resource))
@@ -1831,6 +1851,9 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
account.pendingConferenceLeaves.remove(conversation);
if (account.getStatus() == Account.State.ONLINE) {
conversation.resetMucOptions();
+ if (onConferenceJoined != null) {
+ conversation.getMucOptions().flagNoAutoPushConfiguration();
+ }
conversation.setHasMessagesLeftOnServer(false);
fetchConferenceConfiguration(conversation, new OnConferenceConfigurationFetched() {
@@ -2048,8 +2071,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
}
return;
}
- String localpart = new BigInteger(75, getRNG()).toString(32);
- Jid jid = Jid.fromParts(localpart, server, null);
+ final Jid jid = Jid.fromParts(new BigInteger(64, getRNG()).toString(Character.MAX_RADIX), server, null);
final Conversation conversation = findOrCreateConversation(account, jid, true);
joinMuc(conversation, new OnConferenceJoined() {
@Override
@@ -2058,7 +2080,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
@Override
public void onPushSucceeded() {
if (subject != null && !subject.trim().isEmpty()) {
- pushSubjectToConference(conversation, subject);
+ pushSubjectToConference(conversation, subject.trim());
}
for (Jid invite : jids) {
invite(conversation, invite);
@@ -2066,6 +2088,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
if (account.countPresences() > 1) {
directInvite(conversation, account.getJid().toBareJid());
}
+ saveConversationAsBookmark(conversation, subject);
if (callback != null) {
callback.success(conversation);
}
@@ -2073,6 +2096,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
@Override
public void onPushFailed() {
+ archiveConversation(conversation);
if (callback != null) {
callback.error(R.string.conference_creation_failed, conversation);
}
@@ -3306,6 +3330,21 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
return templates;
}
+ public void saveConversationAsBookmark(Conversation conversation, String name) {
+ Account account = conversation.getAccount();
+ Bookmark bookmark = new Bookmark(account, conversation.getJid().toBareJid());
+ if (!conversation.getJid().isBareJid()) {
+ bookmark.setNick(conversation.getJid().getResourcepart());
+ }
+ if (name != null && !name.trim().isEmpty()) {
+ bookmark.setBookmarkName(name.trim());
+ }
+ bookmark.setAutojoin(getPreferences().getBoolean("autojoin",true));
+ account.getBookmarks().add(bookmark);
+ pushBookmarks(account);
+ conversation.setBookmark(bookmark);
+ }
+
public interface OnMamPreferencesFetched {
void onPreferencesFetched(Element prefs);
void onPreferencesFetchFailed();
diff --git a/src/main/java/eu/siacs/conversations/ui/ChooseContactActivity.java b/src/main/java/eu/siacs/conversations/ui/ChooseContactActivity.java
index 1698343b..5156fcca 100644
--- a/src/main/java/eu/siacs/conversations/ui/ChooseContactActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ChooseContactActivity.java
@@ -1,8 +1,10 @@
package eu.siacs.conversations.ui;
+import android.app.ActionBar;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
+import android.support.annotation.StringRes;
import android.view.ActionMode;
import android.view.Menu;
import android.view.MenuInflater;
@@ -32,6 +34,7 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity {
private Set<Contact> selected;
private Set<String> filterContacts;
+ public static final String EXTRA_TITLE_RES_ID = "extra_title_res_id";
@Override
public void onCreate(final Bundle savedInstanceState) {
@@ -77,6 +80,8 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity {
String[] selection = getSelectedContactJids();
data.putExtra("contacts", selection);
data.putExtra("multiple", true);
+ data.putExtra(EXTRA_ACCOUNT,request.getStringExtra(EXTRA_ACCOUNT));
+ data.putExtra("subject", request.getStringExtra("subject"));
setResult(RESULT_OK, data);
finish();
return true;
@@ -121,6 +126,7 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity {
data.putExtra("conversation",
request.getStringExtra("conversation"));
data.putExtra("multiple", false);
+ data.putExtra("subject", request.getStringExtra("subject"));
setResult(RESULT_OK, data);
finish();
}
@@ -129,6 +135,22 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity {
}
@Override
+ public void onStart() {
+ super.onStart();
+ Intent intent = getIntent();
+ @StringRes
+ int res = intent != null ? intent.getIntExtra(EXTRA_TITLE_RES_ID,R.string.title_activity_choose_contact) : R.string.title_activity_choose_contact;
+ ActionBar bar = getActionBar();
+ if (bar != null) {
+ try {
+ bar.setTitle(res);
+ } catch (Exception e) {
+ bar.setTitle(R.string.title_activity_choose_contact);
+ }
+ }
+ }
+
+ @Override
public boolean onCreateOptionsMenu(final Menu menu) {
super.onCreateOptionsMenu(menu);
final Intent i = getIntent();
@@ -194,6 +216,7 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity {
data.putExtra("conversation",
request.getStringExtra("conversation"));
data.putExtra("multiple", false);
+ data.putExtra("subject", request.getStringExtra("subject"));
setResult(RESULT_OK, data);
finish();
diff --git a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
index f3988313..80ebb28b 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
@@ -26,7 +26,6 @@ import org.openintents.openpgp.util.OpenPgpUtils;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Comparator;
import java.util.concurrent.atomic.AtomicInteger;
import eu.siacs.conversations.Config;
@@ -485,16 +484,8 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
}
protected void saveAsBookmark() {
- Account account = mConversation.getAccount();
- Bookmark bookmark = new Bookmark(account, mConversation.getJid().toBareJid());
- if (!mConversation.getJid().isBareJid()) {
- bookmark.setNick(mConversation.getJid().getResourcepart());
- }
- bookmark.setBookmarkName(mConversation.getMucOptions().getSubject());
- bookmark.setAutojoin(getPreferences().getBoolean("autojoin",true));
- account.getBookmarks().add(bookmark);
- xmppConnectionService.pushBookmarks(account);
- mConversation.setBookmark(bookmark);
+ xmppConnectionService.saveConversationAsBookmark(mConversation,
+ mConversation.getMucOptions().getSubject());
}
protected void deleteBookmark() {
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
index c7fa2d28..a9b9beb7 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
@@ -1122,6 +1122,8 @@ public class ConversationActivity extends XmppActivity
if (mPendingConferenceInvite != null) {
mPendingConferenceInvite.execute(this);
+ mToast = Toast.makeText(this, R.string.creating_conference,Toast.LENGTH_LONG);
+ mToast.show();
mPendingConferenceInvite = null;
}
diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
index 3ab6d1d2..9af83edd 100644
--- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
@@ -10,6 +10,7 @@ import android.app.AlertDialog;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.app.ListFragment;
+import android.app.PendingIntent;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
@@ -27,6 +28,7 @@ import android.support.v4.view.ViewPager;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
+import android.util.Pair;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.KeyEvent;
@@ -54,6 +56,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import java.util.concurrent.RunnableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
import eu.siacs.conversations.Config;
@@ -94,6 +97,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
private EditText mSearchEditText;
private AtomicBoolean mRequestedContactsPermission = new AtomicBoolean(false);
private final int REQUEST_SYNC_CONTACTS = 0x3b28cf;
+ private final int REQUEST_CREATE_CONFERENCE = 0x3b39da;
private MenuItem.OnActionExpandListener mOnActionExpandListener = new MenuItem.OnActionExpandListener() {
@@ -201,6 +205,47 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
}
};
private String mInitialJid;
+ private Pair<Integer, Intent> mPostponedActivityResult;
+ private UiCallback<Conversation> mAdhocConferenceCallback = new UiCallback<Conversation>() {
+ @Override
+ public void success(final Conversation conversation) {
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ hideToast();
+ switchToConversation(conversation);
+ }
+ });
+ }
+
+ @Override
+ public void error(final int errorCode, Conversation object) {
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ replaceToast(getString(errorCode));
+ }
+ });
+ }
+
+ @Override
+ public void userInputRequried(PendingIntent pi, Conversation object) {
+
+ }
+ };
+ private Toast mToast;
+
+ protected void hideToast() {
+ if (mToast != null) {
+ mToast.cancel();
+ }
+ }
+
+ protected void replaceToast(String msg) {
+ hideToast();
+ mToast = Toast.makeText(this, msg ,Toast.LENGTH_LONG);
+ mToast.show();
+ }
@Override
public void onRosterUpdate() {
@@ -488,6 +533,37 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
});
}
+ private void showCreateConferenceDialog() {
+ final AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setTitle(R.string.create_conference);
+ final View dialogView = getLayoutInflater().inflate(R.layout.create_conference_dialog, null);
+ final Spinner spinner = (Spinner) dialogView.findViewById(R.id.account);
+ final EditText subject = (EditText) dialogView.findViewById(R.id.subject);
+ populateAccountSpinner(this, mActivatedAccounts, spinner);
+ builder.setView(dialogView);
+ builder.setPositiveButton(R.string.choose_participants, new OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ if (!xmppConnectionServiceBound) {
+ return;
+ }
+ final Account account = getSelectedAccount(spinner);
+ if (account == null) {
+ return;
+ }
+ Intent intent = new Intent(getApplicationContext(), ChooseContactActivity.class);
+ intent.putExtra("multiple", true);
+ intent.putExtra("show_enter_jid", true);
+ intent.putExtra("subject", subject.getText().toString());
+ intent.putExtra(EXTRA_ACCOUNT, account.getJid().toBareJid().toString());
+ intent.putExtra(ChooseContactActivity.EXTRA_TITLE_RES_ID,R.string.choose_participants);
+ startActivityForResult(intent, REQUEST_CREATE_CONFERENCE);
+ }
+ });
+ builder.setNegativeButton(R.string.cancel, null);
+ builder.create().show();
+ }
+
private Account getSelectedAccount(Spinner spinner) {
if (!spinner.isEnabled()) {
return null;
@@ -532,7 +608,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.start_conversation, menu);
MenuItem menuCreateContact = menu.findItem(R.id.action_create_contact);
- MenuItem menuCreateConference = menu.findItem(R.id.action_join_conference);
+ MenuItem menuCreateConference = menu.findItem(R.id.action_conference);
MenuItem menuHideOffline = menu.findItem(R.id.action_hide_offline);
menuHideOffline.setChecked(this.mHideOfflineContacts);
mMenuSearchView = menu.findItem(R.id.action_search);
@@ -564,6 +640,9 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
case R.id.action_join_conference:
showJoinConferenceDialog(null);
return true;
+ case R.id.action_create_conference:
+ showCreateConferenceDialog();
+ return true;
case R.id.action_scan_qr_code:
new IntentIntegrator(this).initiateScan();
return true;
@@ -616,6 +695,39 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
this.mPendingInvite = null;
}
}
+ } else if (resultCode == RESULT_OK) {
+ if (xmppConnectionServiceBound) {
+ this.mPostponedActivityResult = null;
+ if (requestCode == REQUEST_CREATE_CONFERENCE) {
+ Log.d(Config.LOGTAG,"account jid: "+ intent.getStringExtra(EXTRA_ACCOUNT));
+ Account account = extractAccount(intent);
+ final String subject = intent.getStringExtra("subject");
+ List<Jid> jids = new ArrayList<>();
+ if (intent.getBooleanExtra("multiple", false)) {
+ String[] toAdd = intent.getStringArrayExtra("contacts");
+ for (String item : toAdd) {
+ try {
+ jids.add(Jid.fromString(item));
+ } catch (InvalidJidException e) {
+ //ignored
+ }
+ }
+ } else {
+ try {
+ jids.add(Jid.fromString(intent.getStringExtra("contact")));
+ } catch (Exception e) {
+ //ignored
+ }
+ }
+ if (account != null && jids.size() > 1) {
+ xmppConnectionService.createAdhocConference(account, subject, jids, mAdhocConferenceCallback);
+ mToast = Toast.makeText(this, R.string.creating_conference,Toast.LENGTH_LONG);
+ mToast.show();
+ }
+ }
+ } else {
+ this.mPostponedActivityResult = new Pair<>(requestCode, intent);
+ }
}
super.onActivityResult(requestCode, requestCode, intent);
}
@@ -657,6 +769,10 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
@Override
protected void onBackendConnected() {
+ if (mPostponedActivityResult != null) {
+ onActivityResult(mPostponedActivityResult.first, RESULT_OK, mPostponedActivityResult.second);
+ this.mPostponedActivityResult = null;
+ }
this.mActivatedAccounts.clear();
for (Account account : xmppConnectionService.getAccounts()) {
if (account.getStatus() != Account.State.DISABLED) {
diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
index a136259d..5dfa5083 100644
--- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
@@ -117,6 +117,20 @@ public abstract class XmppActivity extends Activity {
protected int mTheme;
protected boolean mUsingEnterKey = false;
+ protected Toast mToast;
+
+ protected void hideToast() {
+ if (mToast != null) {
+ mToast.cancel();
+ }
+ }
+
+ protected void replaceToast(String msg) {
+ hideToast();
+ mToast = Toast.makeText(this, msg ,Toast.LENGTH_LONG);
+ mToast.show();
+ }
+
protected Runnable onOpenPGPKeyPublished = new Runnable() {
@Override
public void run() {
@@ -940,19 +954,22 @@ public abstract class XmppActivity extends Activity {
mPendingConferenceInvite = ConferenceInvite.parse(data);
if (xmppConnectionServiceBound && mPendingConferenceInvite != null) {
mPendingConferenceInvite.execute(this);
+ mToast = Toast.makeText(this, R.string.creating_conference,Toast.LENGTH_LONG);
+ mToast.show();
mPendingConferenceInvite = null;
}
}
}
+
private UiCallback<Conversation> adhocCallback = new UiCallback<Conversation>() {
@Override
public void success(final Conversation conversation) {
- switchToConversation(conversation);
runOnUiThread(new Runnable() {
@Override
public void run() {
- Toast.makeText(XmppActivity.this,R.string.conference_created,Toast.LENGTH_LONG).show();
+ switchToConversation(conversation);
+ hideToast();
}
});
}
@@ -962,7 +979,7 @@ public abstract class XmppActivity extends Activity {
runOnUiThread(new Runnable() {
@Override
public void run() {
- Toast.makeText(XmppActivity.this,errorCode,Toast.LENGTH_LONG).show();
+ replaceToast(getString(errorCode));
}
});
}
diff --git a/src/main/java/eu/siacs/conversations/utils/CryptoHelper.java b/src/main/java/eu/siacs/conversations/utils/CryptoHelper.java
index 1ef5fb3f..253584bf 100644
--- a/src/main/java/eu/siacs/conversations/utils/CryptoHelper.java
+++ b/src/main/java/eu/siacs/conversations/utils/CryptoHelper.java
@@ -9,6 +9,7 @@ import org.bouncycastle.asn1.x500.style.IETFUtils;
import org.bouncycastle.cert.jcajce.JcaX509CertificateHolder;
import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateParsingException;
import java.security.cert.X509Certificate;
@@ -184,9 +185,7 @@ public final class CryptoHelper {
//ignored
}
try {
- MessageDigest md = MessageDigest.getInstance("SHA-1");
- byte[] fingerprint = md.digest(certificate.getEncoded());
- information.putString("sha1", prettifyFingerprintCert(bytesToHex(fingerprint)));
+ information.putString("sha1", getFingerprintCert(certificate.getEncoded()));
} catch (Exception e) {
}
@@ -196,6 +195,12 @@ public final class CryptoHelper {
}
}
+ public static String getFingerprintCert(byte[] input) throws NoSuchAlgorithmException {
+ MessageDigest md = MessageDigest.getInstance("SHA-1");
+ byte[] fingerprint = md.digest(input);
+ return prettifyFingerprintCert(bytesToHex(fingerprint));
+ }
+
public static int encryptionTypeToText(int encryption) {
switch (encryption) {
case Message.ENCRYPTION_OTR:
diff --git a/src/main/java/eu/siacs/conversations/utils/ExceptionHelper.java b/src/main/java/eu/siacs/conversations/utils/ExceptionHelper.java
index 58d74b58..962613fb 100644
--- a/src/main/java/eu/siacs/conversations/utils/ExceptionHelper.java
+++ b/src/main/java/eu/siacs/conversations/utils/ExceptionHelper.java
@@ -8,6 +8,7 @@ import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.pm.Signature;
import android.preference.PreferenceManager;
import android.text.format.DateUtils;
import android.util.Log;
@@ -18,6 +19,8 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
+import java.text.SimpleDateFormat;
+import java.util.Date;
import java.util.List;
import eu.siacs.conversations.Config;
@@ -31,6 +34,7 @@ import eu.siacs.conversations.xmpp.jid.InvalidJidException;
import eu.siacs.conversations.xmpp.jid.Jid;
public class ExceptionHelper {
+ private static SimpleDateFormat DATE_FORMATs = new SimpleDateFormat("yyyy-MM-dd");
public static void init(Context context) {
if (!(Thread.getDefaultUncaughtExceptionHandler() instanceof ExceptionHandler)) {
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(
@@ -43,7 +47,7 @@ public class ExceptionHelper {
final SharedPreferences preferences = PreferenceManager
.getDefaultSharedPreferences(activity);
boolean neverSend = preferences.getBoolean("never_send", false);
- if (neverSend) {
+ if (neverSend || Config.BUG_REPORTS == null) {
return false;
}
List<Account> accounts = service.getAccounts();
@@ -63,16 +67,18 @@ public class ExceptionHelper {
BufferedReader stacktrace = new BufferedReader(inputStreamReader);
final StringBuilder report = new StringBuilder();
PackageManager pm = activity.getPackageManager();
- PackageInfo packageInfo = null;
+ PackageInfo packageInfo;
try {
- packageInfo = pm.getPackageInfo(activity.getPackageName(), 0);
+ packageInfo = pm.getPackageInfo(activity.getPackageName(), PackageManager.GET_SIGNATURES);
report.append("Version: " + packageInfo.versionName + '\n');
- report.append("Last Update: "
- + DateUtils.formatDateTime(activity,
- packageInfo.lastUpdateTime,
- DateUtils.FORMAT_SHOW_TIME
- | DateUtils.FORMAT_SHOW_DATE) + '\n');
- } catch (NameNotFoundException e) {
+ report.append("Last Update: " + DATE_FORMATs.format(new Date(packageInfo.lastUpdateTime)) + '\n');
+ Signature[] signatures = packageInfo.signatures;
+ if (signatures != null && signatures.length >= 1) {
+ report.append("SHA-1: " + CryptoHelper.getFingerprintCert(packageInfo.signatures[0].toByteArray()) + "\n");
+ }
+ report.append('\n');
+ } catch (Exception e) {
+ e.printStackTrace();
return false;
}
String line;
@@ -97,7 +103,7 @@ public class ExceptionHelper {
Conversation conversation = null;
try {
conversation = service.findOrCreateConversation(finalAccount,
- Jid.fromString("bugs@siacs.eu"), false);
+ Jid.fromString(Config.BUG_REPORTS), false);
} catch (final InvalidJidException ignored) {
}
Message message = new Message(conversation, report