mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-20 22:59:54 +01:00
@@ -111,6 +111,8 @@
|
|||||||
<string name="notify_sound_setting_disabled">None</string>
|
<string name="notify_sound_setting_disabled">None</string>
|
||||||
<string name="choose_ringtone_title">Choose ringtone</string>
|
<string name="choose_ringtone_title">Choose ringtone</string>
|
||||||
<string name="step">Step %1$d/%2$d</string>
|
<string name="step">Step %1$d/%2$d</string>
|
||||||
|
<string name="online">Online</string>
|
||||||
|
<string name="offline">Offline</string>
|
||||||
|
|
||||||
<!-- Dialogs -->
|
<!-- Dialogs -->
|
||||||
<string name="dialog_title_lost_password">Lost password</string>
|
<string name="dialog_title_lost_password">Lost password</string>
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ import org.briarproject.api.db.MessageHeader.State;
|
|||||||
import org.briarproject.api.db.NoSuchContactException;
|
import org.briarproject.api.db.NoSuchContactException;
|
||||||
import org.briarproject.api.db.NoSuchMessageException;
|
import org.briarproject.api.db.NoSuchMessageException;
|
||||||
import org.briarproject.api.db.NoSuchSubscriptionException;
|
import org.briarproject.api.db.NoSuchSubscriptionException;
|
||||||
|
import org.briarproject.api.event.ContactConnectedEvent;
|
||||||
|
import org.briarproject.api.event.ContactDisconnectedEvent;
|
||||||
import org.briarproject.api.event.ContactRemovedEvent;
|
import org.briarproject.api.event.ContactRemovedEvent;
|
||||||
import org.briarproject.api.event.Event;
|
import org.briarproject.api.event.Event;
|
||||||
import org.briarproject.api.event.EventBus;
|
import org.briarproject.api.event.EventBus;
|
||||||
@@ -61,12 +63,14 @@ import org.briarproject.api.messaging.GroupId;
|
|||||||
import org.briarproject.api.messaging.Message;
|
import org.briarproject.api.messaging.Message;
|
||||||
import org.briarproject.api.messaging.MessageFactory;
|
import org.briarproject.api.messaging.MessageFactory;
|
||||||
import org.briarproject.api.messaging.MessageId;
|
import org.briarproject.api.messaging.MessageId;
|
||||||
|
import org.briarproject.api.plugins.ConnectionRegistry;
|
||||||
import org.briarproject.util.StringUtils;
|
import org.briarproject.util.StringUtils;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v7.app.ActionBar;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
@@ -86,6 +90,7 @@ implements EventListener, OnClickListener, OnItemClickListener {
|
|||||||
Logger.getLogger(ConversationActivity.class.getName());
|
Logger.getLogger(ConversationActivity.class.getName());
|
||||||
|
|
||||||
@Inject private AndroidNotificationManager notificationManager;
|
@Inject private AndroidNotificationManager notificationManager;
|
||||||
|
@Inject private ConnectionRegistry connectionRegistry;
|
||||||
@Inject @CryptoExecutor private Executor cryptoExecutor;
|
@Inject @CryptoExecutor private Executor cryptoExecutor;
|
||||||
private Map<MessageId, byte[]> bodyCache = new HashMap<MessageId, byte[]>();
|
private Map<MessageId, byte[]> bodyCache = new HashMap<MessageId, byte[]>();
|
||||||
private TextView empty = null;
|
private TextView empty = null;
|
||||||
@@ -104,6 +109,7 @@ implements EventListener, OnClickListener, OnItemClickListener {
|
|||||||
private volatile GroupId groupId = null;
|
private volatile GroupId groupId = null;
|
||||||
private volatile Group group = null;
|
private volatile Group group = null;
|
||||||
private volatile AuthorId localAuthorId = null;
|
private volatile AuthorId localAuthorId = null;
|
||||||
|
private volatile boolean connected;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle state) {
|
public void onCreate(Bundle state) {
|
||||||
@@ -205,12 +211,13 @@ implements EventListener, OnClickListener, OnItemClickListener {
|
|||||||
localAuthorId = contact.getLocalAuthorId();
|
localAuthorId = contact.getLocalAuthorId();
|
||||||
groupId = db.getInboxGroupId(contactId);
|
groupId = db.getInboxGroupId(contactId);
|
||||||
group = db.getGroup(groupId);
|
group = db.getGroup(groupId);
|
||||||
|
connected = connectionRegistry.isConnected(contactId);
|
||||||
long duration = System.currentTimeMillis() - now;
|
long duration = System.currentTimeMillis() - now;
|
||||||
if (LOG.isLoggable(INFO)) {
|
if (LOG.isLoggable(INFO)) {
|
||||||
LOG.info("Loading contact and group took "
|
LOG.info("Loading contact and group took "
|
||||||
+ duration + " ms");
|
+ duration + " ms");
|
||||||
}
|
}
|
||||||
displayContactName();
|
displayContactDetails();
|
||||||
} catch (NoSuchContactException e) {
|
} catch (NoSuchContactException e) {
|
||||||
finishOnUiThread();
|
finishOnUiThread();
|
||||||
} catch (NoSuchSubscriptionException e) {
|
} catch (NoSuchSubscriptionException e) {
|
||||||
@@ -223,10 +230,18 @@ implements EventListener, OnClickListener, OnItemClickListener {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayContactName() {
|
private void displayContactDetails() {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
setTitle(contactName);
|
ActionBar actionBar = getSupportActionBar();
|
||||||
|
if (actionBar != null) {
|
||||||
|
actionBar.setTitle(contactName);
|
||||||
|
if (connected) {
|
||||||
|
actionBar.setSubtitle(getString(R.string.online));
|
||||||
|
} else {
|
||||||
|
actionBar.setSubtitle(getString(R.string.offline));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -256,7 +271,7 @@ implements EventListener, OnClickListener, OnItemClickListener {
|
|||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
loading.setVisibility(GONE);
|
loading.setVisibility(GONE);
|
||||||
setTitle(contactName);
|
displayContactDetails();
|
||||||
sendButton.setEnabled(true);
|
sendButton.setEnabled(true);
|
||||||
adapter.clear();
|
adapter.clear();
|
||||||
if (headers.isEmpty()) {
|
if (headers.isEmpty()) {
|
||||||
@@ -396,6 +411,20 @@ implements EventListener, OnClickListener, OnItemClickListener {
|
|||||||
LOG.info("Messages acked");
|
LOG.info("Messages acked");
|
||||||
markMessages(m.getMessageIds(), State.DELIVERED);
|
markMessages(m.getMessageIds(), State.DELIVERED);
|
||||||
}
|
}
|
||||||
|
} else if (e instanceof ContactConnectedEvent) {
|
||||||
|
ContactConnectedEvent c = (ContactConnectedEvent) e;
|
||||||
|
if (c.getContactId().equals(contactId)) {
|
||||||
|
LOG.info("Contact connected");
|
||||||
|
connected = true;
|
||||||
|
displayContactDetails();
|
||||||
|
}
|
||||||
|
} else if (e instanceof ContactDisconnectedEvent) {
|
||||||
|
ContactDisconnectedEvent c = (ContactDisconnectedEvent) e;
|
||||||
|
if (c.getContactId().equals(contactId)) {
|
||||||
|
LOG.info("Contact disconnected");
|
||||||
|
connected = false;
|
||||||
|
displayContactDetails();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user