mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Compare commits
7 Commits
macos
...
41-alias-f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
68738a5a03 | ||
|
|
1a025d0f40 | ||
|
|
a3593ea8ca | ||
|
|
34eaedbd63 | ||
|
|
44e1ce32ce | ||
|
|
7af4b3d3ca | ||
|
|
1423ca7a15 |
@@ -10,7 +10,11 @@ import javax.annotation.concurrent.Immutable;
|
|||||||
public class AuthorInfo {
|
public class AuthorInfo {
|
||||||
|
|
||||||
public enum Status {
|
public enum Status {
|
||||||
NONE, ANONYMOUS, UNKNOWN, UNVERIFIED, VERIFIED, OURSELVES
|
NONE, ANONYMOUS, UNKNOWN, UNVERIFIED, VERIFIED, OURSELVES;
|
||||||
|
|
||||||
|
public boolean isContact() {
|
||||||
|
return this == UNVERIFIED || this == VERIFIED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Status status;
|
private final Status status;
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ dependencies {
|
|||||||
implementation "com.android.support:cardview-v7:$supportVersion"
|
implementation "com.android.support:cardview-v7:$supportVersion"
|
||||||
implementation "com.android.support:support-annotations:$supportVersion"
|
implementation "com.android.support:support-annotations:$supportVersion"
|
||||||
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
|
||||||
|
implementation "android.arch.lifecycle:extensions:1.1.1"
|
||||||
|
|
||||||
implementation('ch.acra:acra:4.11') {
|
implementation('ch.acra:acra:4.11') {
|
||||||
exclude module: 'support-v4'
|
exclude module: 'support-v4'
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import org.briarproject.bramble.api.system.LocationUtils;
|
|||||||
import org.briarproject.bramble.plugin.tor.CircumventionProvider;
|
import org.briarproject.bramble.plugin.tor.CircumventionProvider;
|
||||||
import org.briarproject.briar.BriarCoreEagerSingletons;
|
import org.briarproject.briar.BriarCoreEagerSingletons;
|
||||||
import org.briarproject.briar.BriarCoreModule;
|
import org.briarproject.briar.BriarCoreModule;
|
||||||
|
import org.briarproject.briar.android.contact.ConversationViewModel;
|
||||||
import org.briarproject.briar.android.login.SignInReminderReceiver;
|
import org.briarproject.briar.android.login.SignInReminderReceiver;
|
||||||
import org.briarproject.briar.android.reporting.BriarReportSender;
|
import org.briarproject.briar.android.reporting.BriarReportSender;
|
||||||
import org.briarproject.briar.android.view.TextInputView;
|
import org.briarproject.briar.android.view.TextInputView;
|
||||||
@@ -164,6 +165,8 @@ public interface AndroidComponent
|
|||||||
|
|
||||||
void inject(TextInputView textInputView);
|
void inject(TextInputView textInputView);
|
||||||
|
|
||||||
|
void inject(ConversationViewModel conversationViewModel);
|
||||||
|
|
||||||
// Eager singleton load
|
// Eager singleton load
|
||||||
void inject(AppModule.EagerSingletons init);
|
void inject(AppModule.EagerSingletons init);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.identity.Author;
|
|
||||||
import org.briarproject.bramble.api.sync.MessageId;
|
import org.briarproject.bramble.api.sync.MessageId;
|
||||||
import org.briarproject.briar.R;
|
import org.briarproject.briar.R;
|
||||||
import org.briarproject.briar.android.view.AuthorView;
|
import org.briarproject.briar.android.view.AuthorView;
|
||||||
@@ -98,9 +97,7 @@ class BlogPostViewHolder extends RecyclerView.ViewHolder {
|
|||||||
|
|
||||||
// author and date
|
// author and date
|
||||||
BlogPostHeader post = item.getPostHeader();
|
BlogPostHeader post = item.getPostHeader();
|
||||||
Author a = post.getAuthor();
|
author.setAuthor(post.getAuthor(), post.getAuthorInfo());
|
||||||
author.setAuthor(a);
|
|
||||||
author.setAuthorInfo(post.getAuthorInfo());
|
|
||||||
author.setDate(post.getTimestamp());
|
author.setDate(post.getTimestamp());
|
||||||
author.setPersona(
|
author.setPersona(
|
||||||
item.isRssFeed() ? AuthorView.RSS_FEED : AuthorView.NORMAL);
|
item.isRssFeed() ? AuthorView.RSS_FEED : AuthorView.NORMAL);
|
||||||
@@ -143,8 +140,7 @@ class BlogPostViewHolder extends RecyclerView.ViewHolder {
|
|||||||
|
|
||||||
private void onBindComment(BlogCommentItem item) {
|
private void onBindComment(BlogCommentItem item) {
|
||||||
// reblogger
|
// reblogger
|
||||||
reblogger.setAuthor(item.getAuthor());
|
reblogger.setAuthor(item.getAuthor(), item.getAuthorInfo());
|
||||||
reblogger.setAuthorInfo(item.getAuthorInfo());
|
|
||||||
reblogger.setDate(item.getTimestamp());
|
reblogger.setDate(item.getTimestamp());
|
||||||
if (!fullText) {
|
if (!fullText) {
|
||||||
reblogger.setAuthorClickable(v -> listener.onAuthorClick(item));
|
reblogger.setAuthorClickable(v -> listener.onAuthorClick(item));
|
||||||
@@ -165,8 +161,7 @@ class BlogPostViewHolder extends RecyclerView.ViewHolder {
|
|||||||
AuthorView author = v.findViewById(R.id.authorView);
|
AuthorView author = v.findViewById(R.id.authorView);
|
||||||
TextView text = v.findViewById(R.id.textView);
|
TextView text = v.findViewById(R.id.textView);
|
||||||
|
|
||||||
author.setAuthor(c.getAuthor());
|
author.setAuthor(c.getAuthor(), c.getAuthorInfo());
|
||||||
author.setAuthorInfo(c.getAuthorInfo());
|
|
||||||
author.setDate(c.getTimestamp());
|
author.setDate(c.getTimestamp());
|
||||||
// TODO make author clickable #624
|
// TODO make author clickable #624
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
package org.briarproject.briar.android.contact;
|
||||||
|
|
||||||
|
import android.arch.lifecycle.ViewModelProviders;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.v7.app.AppCompatDialogFragment;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
|
||||||
|
import org.briarproject.bramble.api.contact.Contact;
|
||||||
|
import org.briarproject.bramble.api.contact.ContactId;
|
||||||
|
import org.briarproject.briar.R;
|
||||||
|
|
||||||
|
public class AliasDialogFragment extends AppCompatDialogFragment {
|
||||||
|
|
||||||
|
final static String TAG = AliasDialogFragment.class.getName();
|
||||||
|
|
||||||
|
private ConversationViewModel viewModel;
|
||||||
|
private ContactId contactId;
|
||||||
|
private EditText aliasEditText;
|
||||||
|
|
||||||
|
public static AliasDialogFragment newInstance(ContactId id) {
|
||||||
|
AliasDialogFragment f = new AliasDialogFragment();
|
||||||
|
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putInt("contactId", id.getInt());
|
||||||
|
f.setArguments(args);
|
||||||
|
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
if (getArguments() == null) throw new IllegalArgumentException();
|
||||||
|
int contactIdInt = getArguments().getInt("contactId", -1);
|
||||||
|
if (contactIdInt == -1) throw new IllegalArgumentException();
|
||||||
|
contactId = new ContactId(contactIdInt);
|
||||||
|
|
||||||
|
setStyle(STYLE_NO_TITLE, R.style.BriarDialogTheme);
|
||||||
|
|
||||||
|
viewModel =
|
||||||
|
ViewModelProviders.of(getActivity()).get(ConversationViewModel.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||||
|
ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
View v = inflater.inflate(R.layout.fragment_alias_dialog, container,
|
||||||
|
false);
|
||||||
|
|
||||||
|
aliasEditText = v.findViewById(R.id.aliasEditText);
|
||||||
|
Contact contact = viewModel.getContact().getValue();
|
||||||
|
String alias = contact == null ? null : contact.getAlias();
|
||||||
|
aliasEditText.setText(alias);
|
||||||
|
if (alias != null) aliasEditText.setSelection(alias.length());
|
||||||
|
|
||||||
|
Button setButton = v.findViewById(R.id.setButton);
|
||||||
|
setButton.setOnClickListener(v1 -> {
|
||||||
|
viewModel.setContactAlias(contactId,
|
||||||
|
aliasEditText.getText().toString());
|
||||||
|
getDialog().dismiss();
|
||||||
|
});
|
||||||
|
|
||||||
|
Button cancelButton = v.findViewById(R.id.cancelButton);
|
||||||
|
cancelButton.setOnClickListener(v1 -> getDialog().cancel());
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.briarproject.briar.android.contact;
|
package org.briarproject.briar.android.contact;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
import org.briarproject.bramble.api.contact.ContactId;
|
||||||
@@ -9,6 +10,7 @@ import org.briarproject.briar.android.util.BriarAdapter;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import static android.support.v7.util.SortedList.INVALID_POSITION;
|
import static android.support.v7.util.SortedList.INVALID_POSITION;
|
||||||
|
import static org.briarproject.briar.android.util.UiUtils.getContactDisplayName;
|
||||||
|
|
||||||
public abstract class BaseContactListAdapter<I extends ContactItem, VH extends ContactItemViewHolder<I>>
|
public abstract class BaseContactListAdapter<I extends ContactItem, VH extends ContactItemViewHolder<I>>
|
||||||
extends BriarAdapter<I, VH> {
|
extends BriarAdapter<I, VH> {
|
||||||
@@ -23,15 +25,15 @@ public abstract class BaseContactListAdapter<I extends ContactItem, VH extends C
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(VH ui, int position) {
|
public void onBindViewHolder(@NonNull VH ui, int position) {
|
||||||
I item = items.get(position);
|
I item = items.get(position);
|
||||||
ui.bind(item, listener);
|
ui.bind(item, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(I c1, I c2) {
|
public int compare(I c1, I c2) {
|
||||||
return c1.getContact().getAuthor().getName()
|
return getContactDisplayName(c1.getContact())
|
||||||
.compareTo(c2.getContact().getAuthor().getName());
|
.compareTo(getContactDisplayName(c2.getContact()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import javax.annotation.Nullable;
|
|||||||
|
|
||||||
import im.delight.android.identicons.IdenticonDrawable;
|
import im.delight.android.identicons.IdenticonDrawable;
|
||||||
|
|
||||||
|
import static org.briarproject.briar.android.util.UiUtils.getContactDisplayName;
|
||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
public class ContactItemViewHolder<I extends ContactItem>
|
public class ContactItemViewHolder<I extends ContactItem>
|
||||||
@@ -41,8 +43,7 @@ public class ContactItemViewHolder<I extends ContactItem>
|
|||||||
Author author = item.getContact().getAuthor();
|
Author author = item.getContact().getAuthor();
|
||||||
avatar.setImageDrawable(
|
avatar.setImageDrawable(
|
||||||
new IdenticonDrawable(author.getId().getBytes()));
|
new IdenticonDrawable(author.getId().getBytes()));
|
||||||
String contactName = author.getName();
|
name.setText(getContactDisplayName(item.getContact()));
|
||||||
name.setText(contactName);
|
|
||||||
|
|
||||||
if (bulb != null) {
|
if (bulb != null) {
|
||||||
// online/offline
|
// online/offline
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package org.briarproject.briar.android.contact;
|
package org.briarproject.briar.android.contact;
|
||||||
|
|
||||||
import android.arch.lifecycle.MutableLiveData;
|
import android.arch.lifecycle.LiveData;
|
||||||
import android.arch.lifecycle.Observer;
|
import android.arch.lifecycle.Observer;
|
||||||
|
import android.arch.lifecycle.ViewModelProviders;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -23,7 +24,6 @@ import android.widget.TextView;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.FormatException;
|
import org.briarproject.bramble.api.FormatException;
|
||||||
import org.briarproject.bramble.api.contact.Contact;
|
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
import org.briarproject.bramble.api.contact.ContactId;
|
||||||
import org.briarproject.bramble.api.contact.ContactManager;
|
import org.briarproject.bramble.api.contact.ContactManager;
|
||||||
import org.briarproject.bramble.api.contact.event.ContactRemovedEvent;
|
import org.briarproject.bramble.api.contact.event.ContactRemovedEvent;
|
||||||
@@ -34,7 +34,6 @@ import org.briarproject.bramble.api.db.NoSuchContactException;
|
|||||||
import org.briarproject.bramble.api.event.Event;
|
import org.briarproject.bramble.api.event.Event;
|
||||||
import org.briarproject.bramble.api.event.EventBus;
|
import org.briarproject.bramble.api.event.EventBus;
|
||||||
import org.briarproject.bramble.api.event.EventListener;
|
import org.briarproject.bramble.api.event.EventListener;
|
||||||
import org.briarproject.bramble.api.identity.AuthorId;
|
|
||||||
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
||||||
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
||||||
import org.briarproject.bramble.api.plugin.ConnectionRegistry;
|
import org.briarproject.bramble.api.plugin.ConnectionRegistry;
|
||||||
@@ -131,8 +130,8 @@ public class ConversationActivity extends BriarActivity
|
|||||||
Executor cryptoExecutor;
|
Executor cryptoExecutor;
|
||||||
|
|
||||||
private final Map<MessageId, String> textCache = new ConcurrentHashMap<>();
|
private final Map<MessageId, String> textCache = new ConcurrentHashMap<>();
|
||||||
private final MutableLiveData<String> contactName = new MutableLiveData<>();
|
|
||||||
|
|
||||||
|
private ConversationViewModel viewModel;
|
||||||
private ConversationVisitor visitor;
|
private ConversationVisitor visitor;
|
||||||
private ConversationAdapter adapter;
|
private ConversationAdapter adapter;
|
||||||
private Toolbar toolbar;
|
private Toolbar toolbar;
|
||||||
@@ -166,8 +165,6 @@ public class ConversationActivity extends BriarActivity
|
|||||||
|
|
||||||
private volatile ContactId contactId;
|
private volatile ContactId contactId;
|
||||||
@Nullable
|
@Nullable
|
||||||
private volatile AuthorId contactAuthorId;
|
|
||||||
@Nullable
|
|
||||||
private volatile GroupId messagingGroupId;
|
private volatile GroupId messagingGroupId;
|
||||||
|
|
||||||
@SuppressWarnings("ConstantConditions")
|
@SuppressWarnings("ConstantConditions")
|
||||||
@@ -176,6 +173,9 @@ public class ConversationActivity extends BriarActivity
|
|||||||
setSceneTransitionAnimation();
|
setSceneTransitionAnimation();
|
||||||
super.onCreate(state);
|
super.onCreate(state);
|
||||||
|
|
||||||
|
viewModel =
|
||||||
|
ViewModelProviders.of(this).get(ConversationViewModel.class);
|
||||||
|
|
||||||
Intent i = getIntent();
|
Intent i = getIntent();
|
||||||
int id = i.getIntExtra(CONTACT_ID, -1);
|
int id = i.getIntExtra(CONTACT_ID, -1);
|
||||||
if (id == -1) throw new IllegalStateException();
|
if (id == -1) throw new IllegalStateException();
|
||||||
@@ -185,16 +185,29 @@ public class ConversationActivity extends BriarActivity
|
|||||||
|
|
||||||
// Custom Toolbar
|
// Custom Toolbar
|
||||||
toolbar = setUpCustomToolbar(true);
|
toolbar = setUpCustomToolbar(true);
|
||||||
if (toolbar != null) {
|
toolbarAvatar = toolbar.findViewById(R.id.contactAvatar);
|
||||||
toolbarAvatar = toolbar.findViewById(R.id.contactAvatar);
|
toolbarStatus = toolbar.findViewById(R.id.contactStatus);
|
||||||
toolbarStatus = toolbar.findViewById(R.id.contactStatus);
|
toolbarTitle = toolbar.findViewById(R.id.contactName);
|
||||||
toolbarTitle = toolbar.findViewById(R.id.contactName);
|
|
||||||
}
|
viewModel.getContactAuthorId().observe(this, authorId -> {
|
||||||
|
toolbarAvatar.setImageDrawable(
|
||||||
|
new IdenticonDrawable(authorId.getBytes()));
|
||||||
|
// we only need this once
|
||||||
|
viewModel.getContactAuthorId().removeObservers(this);
|
||||||
|
});
|
||||||
|
viewModel.getContactDisplayName().observe(this, contactName -> {
|
||||||
|
toolbarTitle.setText(contactName);
|
||||||
|
});
|
||||||
|
viewModel.isContactDeleted().observe(this, deleted -> {
|
||||||
|
if (deleted != null && deleted) finish();
|
||||||
|
});
|
||||||
|
viewModel.loadContact(contactId);
|
||||||
|
|
||||||
setTransitionName(toolbarAvatar, getAvatarTransitionName(contactId));
|
setTransitionName(toolbarAvatar, getAvatarTransitionName(contactId));
|
||||||
setTransitionName(toolbarStatus, getBulbTransitionName(contactId));
|
setTransitionName(toolbarStatus, getBulbTransitionName(contactId));
|
||||||
|
|
||||||
visitor = new ConversationVisitor(this, this, contactName);
|
visitor = new ConversationVisitor(this, this,
|
||||||
|
viewModel.getContactDisplayName());
|
||||||
adapter = new ConversationAdapter(this, this);
|
adapter = new ConversationAdapter(this, this);
|
||||||
list = findViewById(R.id.conversationView);
|
list = findViewById(R.id.conversationView);
|
||||||
list.setLayoutManager(new LinearLayoutManager(this));
|
list.setLayoutManager(new LinearLayoutManager(this));
|
||||||
@@ -229,7 +242,19 @@ public class ConversationActivity extends BriarActivity
|
|||||||
notificationManager.blockContactNotification(contactId);
|
notificationManager.blockContactNotification(contactId);
|
||||||
notificationManager.clearContactNotification(contactId);
|
notificationManager.clearContactNotification(contactId);
|
||||||
displayContactOnlineStatus();
|
displayContactOnlineStatus();
|
||||||
loadContactDetailsAndMessages();
|
LiveData<String> contactName = viewModel.getContactDisplayName();
|
||||||
|
if (contactName.getValue() == null) {
|
||||||
|
// wait for contact name to be initialized
|
||||||
|
contactName.observe(this, new Observer<String>() {
|
||||||
|
@Override
|
||||||
|
public void onChanged(@Nullable String cName) {
|
||||||
|
if (cName != null) {
|
||||||
|
loadMessages();
|
||||||
|
contactName.removeObserver(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else loadMessages();
|
||||||
list.startPeriodicUpdate();
|
list.startPeriodicUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,6 +291,10 @@ public class ConversationActivity extends BriarActivity
|
|||||||
intent.putExtra(CONTACT_ID, contactId.getInt());
|
intent.putExtra(CONTACT_ID, contactId.getInt());
|
||||||
startActivityForResult(intent, REQUEST_INTRODUCTION);
|
startActivityForResult(intent, REQUEST_INTRODUCTION);
|
||||||
return true;
|
return true;
|
||||||
|
case R.id.action_set_alias:
|
||||||
|
AliasDialogFragment.newInstance(contactId).show(
|
||||||
|
getSupportFragmentManager(), AliasDialogFragment.TAG);
|
||||||
|
return true;
|
||||||
case R.id.action_social_remove_person:
|
case R.id.action_social_remove_person:
|
||||||
askToRemoveContact();
|
askToRemoveContact();
|
||||||
return true;
|
return true;
|
||||||
@@ -274,36 +303,6 @@ public class ConversationActivity extends BriarActivity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadContactDetailsAndMessages() {
|
|
||||||
runOnDbThread(() -> {
|
|
||||||
try {
|
|
||||||
long start = now();
|
|
||||||
if (contactAuthorId == null) {
|
|
||||||
Contact contact = contactManager.getContact(contactId);
|
|
||||||
contactName.postValue(contact.getAuthor().getName());
|
|
||||||
contactAuthorId = contact.getAuthor().getId();
|
|
||||||
}
|
|
||||||
logDuration(LOG, "Loading contact", start);
|
|
||||||
loadMessages();
|
|
||||||
displayContactDetails();
|
|
||||||
} catch (NoSuchContactException e) {
|
|
||||||
finishOnUiThread();
|
|
||||||
} catch (DbException e) {
|
|
||||||
logException(LOG, WARNING, e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// contactAuthorId and contactName are expected to be set
|
|
||||||
private void displayContactDetails() {
|
|
||||||
runOnUiThreadUnlessDestroyed(() -> {
|
|
||||||
//noinspection ConstantConditions
|
|
||||||
toolbarAvatar.setImageDrawable(
|
|
||||||
new IdenticonDrawable(contactAuthorId.getBytes()));
|
|
||||||
toolbarTitle.setText(contactName.getValue());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void displayContactOnlineStatus() {
|
private void displayContactOnlineStatus() {
|
||||||
runOnUiThreadUnlessDestroyed(() -> {
|
runOnUiThreadUnlessDestroyed(() -> {
|
||||||
if (connectionRegistry.isConnected(contactId)) {
|
if (connectionRegistry.isConnected(contactId)) {
|
||||||
@@ -453,15 +452,17 @@ public class ConversationActivity extends BriarActivity
|
|||||||
private void onNewPrivateMessage(PrivateMessageHeader h) {
|
private void onNewPrivateMessage(PrivateMessageHeader h) {
|
||||||
runOnUiThreadUnlessDestroyed(() -> {
|
runOnUiThreadUnlessDestroyed(() -> {
|
||||||
if (h instanceof PrivateRequest || h instanceof PrivateResponse) {
|
if (h instanceof PrivateRequest || h instanceof PrivateResponse) {
|
||||||
String cName = contactName.getValue();
|
String cName = viewModel.getContactDisplayName().getValue();
|
||||||
if (cName == null) {
|
if (cName == null) {
|
||||||
// Wait for the contact name to be loaded
|
// Wait for the contact name to be loaded
|
||||||
contactName.observe(this, new Observer<String>() {
|
viewModel.getContactDisplayName()
|
||||||
|
.observe(this, new Observer<String>() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged(@Nullable String cName) {
|
public void onChanged(@Nullable String cName) {
|
||||||
if (cName != null) {
|
if (cName != null) {
|
||||||
addConversationItem(h.accept(visitor));
|
addConversationItem(h.accept(visitor));
|
||||||
contactName.removeObserver(this);
|
viewModel.getContactDisplayName()
|
||||||
|
.removeObserver(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,100 @@
|
|||||||
|
package org.briarproject.briar.android.contact;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
|
import android.arch.lifecycle.AndroidViewModel;
|
||||||
|
import android.arch.lifecycle.LiveData;
|
||||||
|
import android.arch.lifecycle.MutableLiveData;
|
||||||
|
import android.arch.lifecycle.Transformations;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
|
import org.briarproject.bramble.api.contact.Contact;
|
||||||
|
import org.briarproject.bramble.api.contact.ContactId;
|
||||||
|
import org.briarproject.bramble.api.contact.ContactManager;
|
||||||
|
import org.briarproject.bramble.api.db.DatabaseExecutor;
|
||||||
|
import org.briarproject.bramble.api.db.DbException;
|
||||||
|
import org.briarproject.bramble.api.db.NoSuchContactException;
|
||||||
|
import org.briarproject.bramble.api.identity.AuthorId;
|
||||||
|
import org.briarproject.briar.android.AndroidComponent;
|
||||||
|
import org.briarproject.briar.android.BriarApplication;
|
||||||
|
import org.briarproject.briar.android.util.UiUtils;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import static java.util.logging.Level.WARNING;
|
||||||
|
import static org.briarproject.bramble.util.LogUtils.logDuration;
|
||||||
|
import static org.briarproject.bramble.util.LogUtils.logException;
|
||||||
|
import static org.briarproject.bramble.util.LogUtils.now;
|
||||||
|
|
||||||
|
public class ConversationViewModel extends AndroidViewModel {
|
||||||
|
|
||||||
|
private static Logger LOG =
|
||||||
|
Logger.getLogger(ConversationViewModel.class.getName());
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@DatabaseExecutor
|
||||||
|
Executor dbExecutor;
|
||||||
|
@Inject
|
||||||
|
ContactManager contactManager;
|
||||||
|
|
||||||
|
private final MutableLiveData<Contact> contact = new MutableLiveData<>();
|
||||||
|
private final LiveData<AuthorId> contactAuthorId =
|
||||||
|
Transformations.map(contact, c -> c.getAuthor().getId());
|
||||||
|
private final LiveData<String> contactName =
|
||||||
|
Transformations.map(contact, UiUtils::getContactDisplayName);
|
||||||
|
private final MutableLiveData<Boolean> contactDeleted =
|
||||||
|
new MutableLiveData<>();
|
||||||
|
|
||||||
|
public ConversationViewModel(@NonNull Application application) {
|
||||||
|
super(application);
|
||||||
|
AndroidComponent component =
|
||||||
|
((BriarApplication) application).getApplicationComponent();
|
||||||
|
component.inject(this);
|
||||||
|
contactDeleted.setValue(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadContact(ContactId contactId) {
|
||||||
|
dbExecutor.execute(() -> {
|
||||||
|
try {
|
||||||
|
long start = now();
|
||||||
|
contact.postValue(contactManager.getContact(contactId));
|
||||||
|
logDuration(LOG, "Loading contact", start);
|
||||||
|
} catch (NoSuchContactException e) {
|
||||||
|
contactDeleted.postValue(true);
|
||||||
|
} catch (DbException e) {
|
||||||
|
logException(LOG, WARNING, e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void setContactAlias(ContactId contactId, String alias) {
|
||||||
|
dbExecutor.execute(() -> {
|
||||||
|
try {
|
||||||
|
contactManager.setContactAlias(contactId,
|
||||||
|
alias.isEmpty() ? null : alias);
|
||||||
|
loadContact(contactId);
|
||||||
|
} catch (DbException e) {
|
||||||
|
logException(LOG, WARNING, e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
LiveData<Contact> getContact() {
|
||||||
|
return contact;
|
||||||
|
}
|
||||||
|
|
||||||
|
LiveData<AuthorId> getContactAuthorId() {
|
||||||
|
return contactAuthorId;
|
||||||
|
}
|
||||||
|
|
||||||
|
LiveData<String> getContactDisplayName() {
|
||||||
|
return contactName;
|
||||||
|
}
|
||||||
|
|
||||||
|
LiveData<Boolean> isContactDeleted() {
|
||||||
|
return contactDeleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -24,6 +24,7 @@ import static org.briarproject.briar.android.contact.ConversationRequestItem.Req
|
|||||||
import static org.briarproject.briar.android.contact.ConversationRequestItem.RequestType.FORUM;
|
import static org.briarproject.briar.android.contact.ConversationRequestItem.RequestType.FORUM;
|
||||||
import static org.briarproject.briar.android.contact.ConversationRequestItem.RequestType.GROUP;
|
import static org.briarproject.briar.android.contact.ConversationRequestItem.RequestType.GROUP;
|
||||||
import static org.briarproject.briar.android.contact.ConversationRequestItem.RequestType.INTRODUCTION;
|
import static org.briarproject.briar.android.contact.ConversationRequestItem.RequestType.INTRODUCTION;
|
||||||
|
import static org.briarproject.briar.android.util.UiUtils.getContactDisplayName;
|
||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
@@ -188,33 +189,36 @@ class ConversationVisitor implements PrivateMessageVisitor<ConversationItem> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ConversationItem visitIntroductionRequest(IntroductionRequest r) {
|
public ConversationItem visitIntroductionRequest(IntroductionRequest r) {
|
||||||
|
String name = getContactDisplayName(r.getNameable(), r.getAlias());
|
||||||
if (r.isLocal()) {
|
if (r.isLocal()) {
|
||||||
String text = ctx.getString(R.string.introduction_request_sent,
|
String text = ctx.getString(R.string.introduction_request_sent,
|
||||||
contactName.getValue(), r.getName());
|
contactName.getValue(), name);
|
||||||
return new ConversationNoticeOutItem(text, r);
|
return new ConversationNoticeOutItem(text, r);
|
||||||
} else {
|
} else {
|
||||||
String text = ctx.getString(R.string.introduction_request_received,
|
String text = ctx.getString(R.string.introduction_request_received,
|
||||||
contactName.getValue(), r.getName());
|
contactName.getValue(), name);
|
||||||
return new ConversationRequestItem(text, INTRODUCTION, r);
|
return new ConversationRequestItem(text, INTRODUCTION, r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ConversationItem visitIntroductionResponse(IntroductionResponse r) {
|
public ConversationItem visitIntroductionResponse(IntroductionResponse r) {
|
||||||
|
String introducedAuthor =
|
||||||
|
getContactDisplayName(r.getIntroducedAuthor(),
|
||||||
|
r.getIntroducedAuthorInfo().getAlias());
|
||||||
if (r.isLocal()) {
|
if (r.isLocal()) {
|
||||||
String text;
|
String text;
|
||||||
if (r.wasAccepted()) {
|
if (r.wasAccepted()) {
|
||||||
String introducee = r.getIntroducedAuthor().getName();
|
|
||||||
text = ctx.getString(
|
text = ctx.getString(
|
||||||
R.string.introduction_response_accepted_sent,
|
R.string.introduction_response_accepted_sent,
|
||||||
introducee)
|
introducedAuthor)
|
||||||
+ "\n\n" + ctx.getString(
|
+ "\n\n" + ctx.getString(
|
||||||
R.string.introduction_response_accepted_sent_info,
|
R.string.introduction_response_accepted_sent_info,
|
||||||
introducee);
|
introducedAuthor);
|
||||||
} else {
|
} else {
|
||||||
text = ctx.getString(
|
text = ctx.getString(
|
||||||
R.string.introduction_response_declined_sent,
|
R.string.introduction_response_declined_sent,
|
||||||
r.getIntroducedAuthor().getName());
|
introducedAuthor);
|
||||||
}
|
}
|
||||||
return new ConversationNoticeOutItem(text, r);
|
return new ConversationNoticeOutItem(text, r);
|
||||||
} else {
|
} else {
|
||||||
@@ -223,17 +227,17 @@ class ConversationVisitor implements PrivateMessageVisitor<ConversationItem> {
|
|||||||
text = ctx.getString(
|
text = ctx.getString(
|
||||||
R.string.introduction_response_accepted_received,
|
R.string.introduction_response_accepted_received,
|
||||||
contactName.getValue(),
|
contactName.getValue(),
|
||||||
r.getIntroducedAuthor().getName());
|
introducedAuthor);
|
||||||
} else if (r.isIntroducer()) {
|
} else if (r.isIntroducer()) {
|
||||||
text = ctx.getString(
|
text = ctx.getString(
|
||||||
R.string.introduction_response_declined_received,
|
R.string.introduction_response_declined_received,
|
||||||
contactName.getValue(),
|
contactName.getValue(),
|
||||||
r.getIntroducedAuthor().getName());
|
introducedAuthor);
|
||||||
} else {
|
} else {
|
||||||
text = ctx.getString(
|
text = ctx.getString(
|
||||||
R.string.introduction_response_declined_received_by_introducee,
|
R.string.introduction_response_declined_received_by_introducee,
|
||||||
contactName.getValue(),
|
contactName.getValue(),
|
||||||
r.getIntroducedAuthor().getName());
|
introducedAuthor);
|
||||||
}
|
}
|
||||||
return new ConversationNoticeInItem(text, r);
|
return new ConversationNoticeInItem(text, r);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import static android.view.View.VISIBLE;
|
|||||||
import static android.widget.Toast.LENGTH_SHORT;
|
import static android.widget.Toast.LENGTH_SHORT;
|
||||||
import static java.util.logging.Level.WARNING;
|
import static java.util.logging.Level.WARNING;
|
||||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
import static org.briarproject.bramble.util.LogUtils.logException;
|
||||||
|
import static org.briarproject.briar.android.util.UiUtils.getContactDisplayName;
|
||||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.MAX_INTRODUCTION_TEXT_LENGTH;
|
import static org.briarproject.briar.api.introduction.IntroductionConstants.MAX_INTRODUCTION_TEXT_LENGTH;
|
||||||
|
|
||||||
public class IntroductionMessageFragment extends BaseFragment
|
public class IntroductionMessageFragment extends BaseFragment
|
||||||
@@ -148,8 +149,8 @@ public class IntroductionMessageFragment extends BaseFragment
|
|||||||
c2.getAuthor().getId().getBytes()));
|
c2.getAuthor().getId().getBytes()));
|
||||||
|
|
||||||
// set contact names
|
// set contact names
|
||||||
ui.contactName1.setText(c1.getAuthor().getName());
|
ui.contactName1.setText(getContactDisplayName(c1));
|
||||||
ui.contactName2.setText(c2.getAuthor().getName());
|
ui.contactName2.setText(getContactDisplayName(c2));
|
||||||
|
|
||||||
// hide progress bar
|
// hide progress bar
|
||||||
ui.progressBar.setVisibility(GONE);
|
ui.progressBar.setVisibility(GONE);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import org.briarproject.briar.android.threaded.BaseThreadItemViewHolder;
|
|||||||
import org.briarproject.briar.android.threaded.ThreadItemAdapter.ThreadItemListener;
|
import org.briarproject.briar.android.threaded.ThreadItemAdapter.ThreadItemListener;
|
||||||
|
|
||||||
import static org.briarproject.bramble.api.identity.AuthorInfo.Status.OURSELVES;
|
import static org.briarproject.bramble.api.identity.AuthorInfo.Status.OURSELVES;
|
||||||
|
import static org.briarproject.briar.android.util.UiUtils.getContactDisplayName;
|
||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
@@ -36,24 +37,27 @@ class JoinMessageItemViewHolder
|
|||||||
if (item.isInitial()) {
|
if (item.isInitial()) {
|
||||||
textView.setText(R.string.groups_member_created_you);
|
textView.setText(R.string.groups_member_created_you);
|
||||||
} else {
|
} else {
|
||||||
textView.setText(
|
String name = getContactDisplayName(item.getAuthor(),
|
||||||
getContext().getString(R.string.groups_member_joined,
|
item.getAuthorInfo().getAlias());
|
||||||
item.getAuthor().getName()));
|
textView.setText(getContext()
|
||||||
|
.getString(R.string.groups_member_joined, name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bind(JoinMessageItem item) {
|
private void bind(JoinMessageItem item) {
|
||||||
Context ctx = getContext();
|
Context ctx = getContext();
|
||||||
|
String name = getContactDisplayName(item.getAuthor(),
|
||||||
|
item.getAuthorInfo().getAlias());
|
||||||
|
|
||||||
if (item.isInitial()) {
|
if (item.isInitial()) {
|
||||||
textView.setText(ctx.getString(R.string.groups_member_created,
|
textView.setText(
|
||||||
item.getAuthor().getName()));
|
ctx.getString(R.string.groups_member_created, name));
|
||||||
} else {
|
} else {
|
||||||
if (item.getAuthorInfo().getStatus() == OURSELVES) {
|
if (item.getAuthorInfo().getStatus() == OURSELVES) {
|
||||||
textView.setText(R.string.groups_member_joined_you);
|
textView.setText(R.string.groups_member_joined_you);
|
||||||
} else {
|
} else {
|
||||||
textView.setText(ctx.getString(R.string.groups_member_joined,
|
textView.setText(
|
||||||
item.getAuthor().getName()));
|
ctx.getString(R.string.groups_member_joined, name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import org.briarproject.briar.api.privategroup.invitation.GroupInvitationItem;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import static org.briarproject.briar.android.util.UiUtils.getContactDisplayName;
|
||||||
|
|
||||||
class GroupInvitationViewHolder
|
class GroupInvitationViewHolder
|
||||||
extends InvitationViewHolder<GroupInvitationItem> {
|
extends InvitationViewHolder<GroupInvitationItem> {
|
||||||
|
|
||||||
@@ -24,7 +26,7 @@ class GroupInvitationViewHolder
|
|||||||
|
|
||||||
sharedBy.setText(
|
sharedBy.setText(
|
||||||
sharedBy.getContext().getString(R.string.groups_created_by,
|
sharedBy.getContext().getString(R.string.groups_created_by,
|
||||||
item.getCreator().getAuthor().getName()));
|
getContactDisplayName(item.getCreator())));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.briarproject.briar.android.privategroup.list;
|
package org.briarproject.briar.android.privategroup.list;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.identity.Author;
|
import org.briarproject.bramble.api.identity.Author;
|
||||||
|
import org.briarproject.bramble.api.identity.AuthorInfo;
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.sync.GroupId;
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
import org.briarproject.briar.api.client.MessageTracker.GroupCount;
|
import org.briarproject.briar.api.client.MessageTracker.GroupCount;
|
||||||
@@ -12,12 +13,15 @@ import org.briarproject.briar.api.privategroup.PrivateGroup;
|
|||||||
class GroupItem {
|
class GroupItem {
|
||||||
|
|
||||||
private final PrivateGroup privateGroup;
|
private final PrivateGroup privateGroup;
|
||||||
|
private final AuthorInfo authorInfo;
|
||||||
private int messageCount, unreadCount;
|
private int messageCount, unreadCount;
|
||||||
private long timestamp;
|
private long timestamp;
|
||||||
private boolean dissolved;
|
private boolean dissolved;
|
||||||
|
|
||||||
GroupItem(PrivateGroup privateGroup, GroupCount count, boolean dissolved) {
|
GroupItem(PrivateGroup privateGroup, AuthorInfo authorInfo,
|
||||||
|
GroupCount count, boolean dissolved) {
|
||||||
this.privateGroup = privateGroup;
|
this.privateGroup = privateGroup;
|
||||||
|
this.authorInfo = authorInfo;
|
||||||
this.messageCount = count.getMsgCount();
|
this.messageCount = count.getMsgCount();
|
||||||
this.unreadCount = count.getUnreadCount();
|
this.unreadCount = count.getUnreadCount();
|
||||||
this.timestamp = count.getLatestMsgTime();
|
this.timestamp = count.getLatestMsgTime();
|
||||||
@@ -46,6 +50,10 @@ class GroupItem {
|
|||||||
return privateGroup.getCreator();
|
return privateGroup.getCreator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AuthorInfo getCreatorInfo() {
|
||||||
|
return authorInfo;
|
||||||
|
}
|
||||||
|
|
||||||
String getName() {
|
String getName() {
|
||||||
return privateGroup.getName();
|
return privateGroup.getName();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,15 @@ package org.briarproject.briar.android.privategroup.list;
|
|||||||
|
|
||||||
import android.support.annotation.CallSuper;
|
import android.support.annotation.CallSuper;
|
||||||
|
|
||||||
|
import org.briarproject.bramble.api.contact.ContactManager;
|
||||||
import org.briarproject.bramble.api.db.DatabaseExecutor;
|
import org.briarproject.bramble.api.db.DatabaseExecutor;
|
||||||
import org.briarproject.bramble.api.db.DbException;
|
import org.briarproject.bramble.api.db.DbException;
|
||||||
import org.briarproject.bramble.api.db.NoSuchGroupException;
|
import org.briarproject.bramble.api.db.NoSuchGroupException;
|
||||||
import org.briarproject.bramble.api.event.Event;
|
import org.briarproject.bramble.api.event.Event;
|
||||||
import org.briarproject.bramble.api.event.EventBus;
|
import org.briarproject.bramble.api.event.EventBus;
|
||||||
import org.briarproject.bramble.api.event.EventListener;
|
import org.briarproject.bramble.api.event.EventListener;
|
||||||
|
import org.briarproject.bramble.api.identity.AuthorId;
|
||||||
|
import org.briarproject.bramble.api.identity.AuthorInfo;
|
||||||
import org.briarproject.bramble.api.lifecycle.LifecycleManager;
|
import org.briarproject.bramble.api.lifecycle.LifecycleManager;
|
||||||
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
||||||
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
||||||
@@ -30,7 +33,9 @@ import org.briarproject.briar.api.privategroup.invitation.GroupInvitationManager
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -52,6 +57,7 @@ class GroupListControllerImpl extends DbControllerImpl
|
|||||||
|
|
||||||
private final PrivateGroupManager groupManager;
|
private final PrivateGroupManager groupManager;
|
||||||
private final GroupInvitationManager groupInvitationManager;
|
private final GroupInvitationManager groupInvitationManager;
|
||||||
|
private final ContactManager contactManager;
|
||||||
private final AndroidNotificationManager notificationManager;
|
private final AndroidNotificationManager notificationManager;
|
||||||
private final EventBus eventBus;
|
private final EventBus eventBus;
|
||||||
|
|
||||||
@@ -61,10 +67,12 @@ class GroupListControllerImpl extends DbControllerImpl
|
|||||||
GroupListControllerImpl(@DatabaseExecutor Executor dbExecutor,
|
GroupListControllerImpl(@DatabaseExecutor Executor dbExecutor,
|
||||||
LifecycleManager lifecycleManager, PrivateGroupManager groupManager,
|
LifecycleManager lifecycleManager, PrivateGroupManager groupManager,
|
||||||
GroupInvitationManager groupInvitationManager,
|
GroupInvitationManager groupInvitationManager,
|
||||||
|
ContactManager contactManager,
|
||||||
AndroidNotificationManager notificationManager, EventBus eventBus) {
|
AndroidNotificationManager notificationManager, EventBus eventBus) {
|
||||||
super(dbExecutor, lifecycleManager);
|
super(dbExecutor, lifecycleManager);
|
||||||
this.groupManager = groupManager;
|
this.groupManager = groupManager;
|
||||||
this.groupInvitationManager = groupInvitationManager;
|
this.groupInvitationManager = groupInvitationManager;
|
||||||
|
this.contactManager = contactManager;
|
||||||
this.notificationManager = notificationManager;
|
this.notificationManager = notificationManager;
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
}
|
}
|
||||||
@@ -153,12 +161,22 @@ class GroupListControllerImpl extends DbControllerImpl
|
|||||||
Collection<PrivateGroup> groups =
|
Collection<PrivateGroup> groups =
|
||||||
groupManager.getPrivateGroups();
|
groupManager.getPrivateGroups();
|
||||||
List<GroupItem> items = new ArrayList<>(groups.size());
|
List<GroupItem> items = new ArrayList<>(groups.size());
|
||||||
|
Map<AuthorId, AuthorInfo> authorInfos = new HashMap<>();
|
||||||
for (PrivateGroup g : groups) {
|
for (PrivateGroup g : groups) {
|
||||||
try {
|
try {
|
||||||
GroupId id = g.getId();
|
GroupId id = g.getId();
|
||||||
|
AuthorId authorId = g.getCreator().getId();
|
||||||
|
AuthorInfo authorInfo;
|
||||||
|
if (authorInfos.containsKey(authorId)) {
|
||||||
|
authorInfo = authorInfos.get(authorId);
|
||||||
|
} else {
|
||||||
|
authorInfo = contactManager.getAuthorInfo(authorId);
|
||||||
|
authorInfos.put(authorId, authorInfo);
|
||||||
|
}
|
||||||
GroupCount count = groupManager.getGroupCount(id);
|
GroupCount count = groupManager.getGroupCount(id);
|
||||||
boolean dissolved = groupManager.isDissolved(id);
|
boolean dissolved = groupManager.isDissolved(id);
|
||||||
items.add(new GroupItem(g, count, dissolved));
|
items.add(
|
||||||
|
new GroupItem(g, authorInfo, count, dissolved));
|
||||||
} catch (NoSuchGroupException e) {
|
} catch (NoSuchGroupException e) {
|
||||||
// Continue
|
// Continue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import static android.view.View.GONE;
|
|||||||
import static android.view.View.VISIBLE;
|
import static android.view.View.VISIBLE;
|
||||||
import static org.briarproject.briar.android.activity.BriarActivity.GROUP_ID;
|
import static org.briarproject.briar.android.activity.BriarActivity.GROUP_ID;
|
||||||
import static org.briarproject.briar.android.activity.BriarActivity.GROUP_NAME;
|
import static org.briarproject.briar.android.activity.BriarActivity.GROUP_NAME;
|
||||||
|
import static org.briarproject.briar.android.util.UiUtils.getContactDisplayName;
|
||||||
|
|
||||||
@MethodsNotNullByDefault
|
@MethodsNotNullByDefault
|
||||||
@ParametersNotNullByDefault
|
@ParametersNotNullByDefault
|
||||||
@@ -60,8 +61,9 @@ class GroupViewHolder extends RecyclerView.ViewHolder {
|
|||||||
name.setText(group.getName());
|
name.setText(group.getName());
|
||||||
|
|
||||||
// Creator
|
// Creator
|
||||||
creator.setText(ctx.getString(R.string.groups_created_by,
|
String creatorName = getContactDisplayName(group.getCreator(),
|
||||||
group.getCreator().getName()));
|
group.getCreatorInfo().getAlias());
|
||||||
|
creator.setText(ctx.getString(R.string.groups_created_by, creatorName));
|
||||||
|
|
||||||
if (!group.isDissolved()) {
|
if (!group.isDissolved()) {
|
||||||
// full visibility
|
// full visibility
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.briarproject.briar.android.privategroup.memberlist;
|
package org.briarproject.briar.android.privategroup.memberlist;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -8,6 +9,8 @@ import android.view.ViewGroup;
|
|||||||
import org.briarproject.briar.R;
|
import org.briarproject.briar.R;
|
||||||
import org.briarproject.briar.android.util.BriarAdapter;
|
import org.briarproject.briar.android.util.BriarAdapter;
|
||||||
|
|
||||||
|
import static org.briarproject.briar.android.util.UiUtils.getContactDisplayName;
|
||||||
|
|
||||||
class MemberListAdapter extends
|
class MemberListAdapter extends
|
||||||
BriarAdapter<MemberListItem, MemberListItemHolder> {
|
BriarAdapter<MemberListItem, MemberListItemHolder> {
|
||||||
|
|
||||||
@@ -15,8 +18,9 @@ class MemberListAdapter extends
|
|||||||
super(context, MemberListItem.class);
|
super(context, MemberListItem.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public MemberListItemHolder onCreateViewHolder(ViewGroup viewGroup,
|
public MemberListItemHolder onCreateViewHolder(@NonNull ViewGroup viewGroup,
|
||||||
int i) {
|
int i) {
|
||||||
View v = LayoutInflater.from(ctx).inflate(
|
View v = LayoutInflater.from(ctx).inflate(
|
||||||
R.layout.list_item_group_member, viewGroup, false);
|
R.layout.list_item_group_member, viewGroup, false);
|
||||||
@@ -24,13 +28,18 @@ class MemberListAdapter extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(MemberListItemHolder ui, int position) {
|
public void onBindViewHolder(@NonNull MemberListItemHolder ui,
|
||||||
|
int position) {
|
||||||
ui.bind(items.get(position));
|
ui.bind(items.get(position));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(MemberListItem m1, MemberListItem m2) {
|
public int compare(MemberListItem m1, MemberListItem m2) {
|
||||||
return m1.getMember().getName().compareTo(m2.getMember().getName());
|
String n1 = getContactDisplayName(m1.getMember(),
|
||||||
|
m1.getAuthorInfo().getAlias());
|
||||||
|
String n2 = getContactDisplayName(m2.getMember(),
|
||||||
|
m2.getAuthorInfo().getAlias());
|
||||||
|
return n1.compareTo(n2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import org.briarproject.briar.android.view.AuthorView;
|
|||||||
import static android.view.View.GONE;
|
import static android.view.View.GONE;
|
||||||
import static android.view.View.VISIBLE;
|
import static android.view.View.VISIBLE;
|
||||||
import static org.briarproject.bramble.api.identity.AuthorInfo.Status.OURSELVES;
|
import static org.briarproject.bramble.api.identity.AuthorInfo.Status.OURSELVES;
|
||||||
|
import static org.briarproject.briar.android.util.UiUtils.getContactDisplayName;
|
||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
@@ -31,8 +32,7 @@ class MemberListItemHolder extends RecyclerView.ViewHolder {
|
|||||||
|
|
||||||
protected void bind(MemberListItem item) {
|
protected void bind(MemberListItem item) {
|
||||||
// member name, avatar and status
|
// member name, avatar and status
|
||||||
author.setAuthor(item.getMember());
|
author.setAuthor(item.getMember(), item.getAuthorInfo());
|
||||||
author.setAuthorInfo(item.getAuthorInfo());
|
|
||||||
|
|
||||||
// online status of visible contacts
|
// online status of visible contacts
|
||||||
if (item.getContactId() != null) {
|
if (item.getContactId() != null) {
|
||||||
@@ -52,9 +52,10 @@ class MemberListItemHolder extends RecyclerView.ViewHolder {
|
|||||||
if (item.getStatus() == OURSELVES) {
|
if (item.getStatus() == OURSELVES) {
|
||||||
creator.setText(R.string.groups_member_created_you);
|
creator.setText(R.string.groups_member_created_you);
|
||||||
} else {
|
} else {
|
||||||
|
String name = getContactDisplayName(item.getMember(),
|
||||||
|
item.getAuthorInfo().getAlias());
|
||||||
creator.setText(creator.getContext()
|
creator.setText(creator.getContext()
|
||||||
.getString(R.string.groups_member_created,
|
.getString(R.string.groups_member_created, name));
|
||||||
item.getMember().getName()));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
creator.setVisibility(GONE);
|
creator.setVisibility(GONE);
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import javax.annotation.Nullable;
|
|||||||
import static org.briarproject.briar.android.privategroup.VisibilityHelper.getVisibilityIcon;
|
import static org.briarproject.briar.android.privategroup.VisibilityHelper.getVisibilityIcon;
|
||||||
import static org.briarproject.briar.android.privategroup.VisibilityHelper.getVisibilityString;
|
import static org.briarproject.briar.android.privategroup.VisibilityHelper.getVisibilityString;
|
||||||
import static org.briarproject.briar.android.util.UiUtils.GREY_OUT;
|
import static org.briarproject.briar.android.util.UiUtils.GREY_OUT;
|
||||||
|
import static org.briarproject.briar.android.util.UiUtils.getContactDisplayName;
|
||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
@@ -36,7 +37,7 @@ class RevealableContactViewHolder
|
|||||||
icon.setImageResource(getVisibilityIcon(item.getVisibility()));
|
icon.setImageResource(getVisibilityIcon(item.getVisibility()));
|
||||||
info.setText(
|
info.setText(
|
||||||
getVisibilityString(info.getContext(), item.getVisibility(),
|
getVisibilityString(info.getContext(), item.getVisibility(),
|
||||||
item.getContact().getAuthor().getName()));
|
getContactDisplayName(item.getContact())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import java.util.Collection;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import static org.briarproject.briar.android.util.UiUtils.getContactDisplayName;
|
||||||
|
|
||||||
class SharingInvitationViewHolder
|
class SharingInvitationViewHolder
|
||||||
extends InvitationViewHolder<SharingInvitationItem> {
|
extends InvitationViewHolder<SharingInvitationItem> {
|
||||||
|
|
||||||
@@ -28,7 +30,7 @@ class SharingInvitationViewHolder
|
|||||||
|
|
||||||
Collection<String> names = new ArrayList<>();
|
Collection<String> names = new ArrayList<>();
|
||||||
for (Contact c : item.getNewSharers())
|
for (Contact c : item.getNewSharers())
|
||||||
names.add(c.getAuthor().getName());
|
names.add(getContactDisplayName(c));
|
||||||
sharedBy.setText(
|
sharedBy.setText(
|
||||||
sharedBy.getContext().getString(R.string.shared_by_format,
|
sharedBy.getContext().getString(R.string.shared_by_format,
|
||||||
StringUtils.join(names, ", ")));
|
StringUtils.join(names, ", ")));
|
||||||
|
|||||||
@@ -43,9 +43,8 @@ public abstract class BaseThreadItemViewHolder<I extends ThreadItem>
|
|||||||
public void bind(I item, ThreadItemListener<I> listener) {
|
public void bind(I item, ThreadItemListener<I> listener) {
|
||||||
textView.setText(StringUtils.trim(item.getText()));
|
textView.setText(StringUtils.trim(item.getText()));
|
||||||
|
|
||||||
author.setAuthor(item.getAuthor());
|
author.setAuthor(item.getAuthor(), item.getAuthorInfo());
|
||||||
author.setDate(item.getTimestamp());
|
author.setDate(item.getTimestamp());
|
||||||
author.setAuthorInfo(item.getAuthorInfo());
|
|
||||||
|
|
||||||
if (item.isHighlighted()) {
|
if (item.isHighlighted()) {
|
||||||
layout.setActivated(true);
|
layout.setActivated(true);
|
||||||
|
|||||||
@@ -33,7 +33,9 @@ import android.view.View;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.acra.ACRA;
|
import org.acra.ACRA;
|
||||||
|
import org.briarproject.bramble.api.contact.Contact;
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
import org.briarproject.bramble.api.contact.ContactId;
|
||||||
|
import org.briarproject.bramble.api.identity.Author;
|
||||||
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.MethodsNotNullByDefault;
|
||||||
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
|
||||||
import org.briarproject.bramble.api.system.AndroidExecutor;
|
import org.briarproject.bramble.api.system.AndroidExecutor;
|
||||||
@@ -74,6 +76,17 @@ public class UiUtils {
|
|||||||
public static final int TEASER_LENGTH = 320;
|
public static final int TEASER_LENGTH = 320;
|
||||||
public static final float GREY_OUT = 0.5f;
|
public static final float GREY_OUT = 0.5f;
|
||||||
|
|
||||||
|
public static String getContactDisplayName(Author author,
|
||||||
|
@Nullable String alias) {
|
||||||
|
String name = author.getName();
|
||||||
|
if (alias == null) return name;
|
||||||
|
else return String.format("%s (%s)", alias, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getContactDisplayName(Contact c) {
|
||||||
|
return getContactDisplayName(c.getAuthor(), c.getAlias());
|
||||||
|
}
|
||||||
|
|
||||||
public static void setError(TextInputLayout til, @Nullable String error,
|
public static void setError(TextInputLayout til, @Nullable String error,
|
||||||
boolean set) {
|
boolean set) {
|
||||||
if (set) {
|
if (set) {
|
||||||
@@ -127,7 +140,9 @@ public class UiUtils {
|
|||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Spanned getSpanned(String s) {
|
public static Spanned getSpanned(@Nullable String s) {
|
||||||
|
// TODO move to HtmlCompat
|
||||||
|
// https://commonsware.com/blog/2018/05/29/at-last-htmlcompat.html
|
||||||
return Html.fromHtml(s);
|
return Html.fromHtml(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import static android.graphics.Typeface.BOLD;
|
|||||||
import static android.util.TypedValue.COMPLEX_UNIT_PX;
|
import static android.util.TypedValue.COMPLEX_UNIT_PX;
|
||||||
import static org.briarproject.bramble.api.identity.AuthorInfo.Status.NONE;
|
import static org.briarproject.bramble.api.identity.AuthorInfo.Status.NONE;
|
||||||
import static org.briarproject.bramble.api.identity.AuthorInfo.Status.OURSELVES;
|
import static org.briarproject.bramble.api.identity.AuthorInfo.Status.OURSELVES;
|
||||||
|
import static org.briarproject.briar.android.util.UiUtils.getContactDisplayName;
|
||||||
import static org.briarproject.briar.android.util.UiUtils.resolveAttribute;
|
import static org.briarproject.briar.android.util.UiUtils.resolveAttribute;
|
||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
@@ -70,16 +71,12 @@ public class AuthorView extends ConstraintLayout {
|
|||||||
this(context, null);
|
this(context, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAuthor(Author author) {
|
public void setAuthor(Author author, AuthorInfo authorInfo) {
|
||||||
authorName.setText(author.getName());
|
authorName
|
||||||
|
.setText(getContactDisplayName(author, authorInfo.getAlias()));
|
||||||
IdenticonDrawable d = new IdenticonDrawable(author.getId().getBytes());
|
IdenticonDrawable d = new IdenticonDrawable(author.getId().getBytes());
|
||||||
avatar.setImageDrawable(d);
|
avatar.setImageDrawable(d);
|
||||||
|
|
||||||
invalidate();
|
|
||||||
requestLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAuthorInfo(AuthorInfo authorInfo) {
|
|
||||||
if (authorInfo.getStatus() != NONE) {
|
if (authorInfo.getStatus() != NONE) {
|
||||||
trustIndicator.setTrustLevel(authorInfo.getStatus());
|
trustIndicator.setTrustLevel(authorInfo.getStatus());
|
||||||
trustIndicator.setVisibility(VISIBLE);
|
trustIndicator.setVisibility(VISIBLE);
|
||||||
@@ -123,7 +120,7 @@ public class AuthorView extends ConstraintLayout {
|
|||||||
*
|
*
|
||||||
* Attention: RSS_FEED and RSS_FEED_REBLOGGED change the avatar
|
* Attention: RSS_FEED and RSS_FEED_REBLOGGED change the avatar
|
||||||
* and override the one set by
|
* and override the one set by
|
||||||
* {@link AuthorView#setAuthor(Author)}.
|
* {@link AuthorView#setAuthor(Author, AuthorInfo)}.
|
||||||
*/
|
*/
|
||||||
public void setPersona(int persona) {
|
public void setPersona(int persona) {
|
||||||
switch (persona) {
|
switch (persona) {
|
||||||
|
|||||||
52
briar-android/src/main/res/layout/fragment_alias_dialog.xml
Normal file
52
briar-android/src/main/res/layout/fragment_alias_dialog.xml
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="16dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/titleView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/set_contact_alias"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:textSize="@dimen/text_size_large"
|
||||||
|
android:textStyle="bold"/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/aliasEditText"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:hint="@string/set_contact_alias_hint"
|
||||||
|
android:inputType="textPersonName"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:textSize="@dimen/text_size_medium"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="@dimen/margin_xxlarge"
|
||||||
|
android:layout_marginStart="@dimen/margin_xxlarge"
|
||||||
|
android:gravity="end"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/cancelButton"
|
||||||
|
style="@style/BriarButtonFlat.Negative"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/cancel"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/setButton"
|
||||||
|
style="@style/BriarButtonFlat.Positive"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/set_alias"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -1,75 +1,69 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"
|
||||||
|
android:padding="16dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/link_warning_title"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:textSize="@dimen/text_size_large"
|
||||||
|
android:textStyle="bold"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/margin_large"
|
||||||
|
android:text="@string/link_warning_intro"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:textSize="@dimen/text_size_medium"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/urlView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/margin_large"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:textIsSelectable="true"
|
||||||
|
android:textSize="@dimen/text_size_medium"
|
||||||
|
android:typeface="monospace"
|
||||||
|
tools:text="http://very.bad.site.com"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/margin_large"
|
||||||
|
android:text="@string/link_warning_text"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:textSize="@dimen/text_size_medium"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="@dimen/margin_large">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/link_warning_title"
|
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
|
||||||
android:textSize="@dimen/text_size_large"
|
|
||||||
android:textStyle="bold"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="@dimen/margin_large"
|
|
||||||
android:text="@string/link_warning_intro"
|
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
|
||||||
android:textSize="@dimen/text_size_medium"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/urlView"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="@dimen/margin_large"
|
|
||||||
android:textIsSelectable="true"
|
|
||||||
android:typeface="monospace"
|
|
||||||
tools:text="http://very.bad.site.com"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="@dimen/margin_large"
|
|
||||||
android:text="@string/link_warning_text"
|
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
|
||||||
android:textSize="@dimen/text_size_medium"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<android.support.constraint.ConstraintLayout
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/button_size">
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="@dimen/margin_xxlarge"
|
||||||
|
android:layout_marginStart="@dimen/margin_xxlarge"
|
||||||
|
android:gravity="end"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/cancelButton"
|
android:id="@+id/cancelButton"
|
||||||
style="@style/BriarButtonFlat.Positive"
|
style="@style/BriarButtonFlat.Positive"
|
||||||
android:layout_width="0dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/cancel"
|
android:text="@string/cancel"/>
|
||||||
app:layout_constraintEnd_toStartOf="@+id/openButton"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"/>
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/openButton"
|
android:id="@+id/openButton"
|
||||||
style="@style/BriarButtonFlat.Negative"
|
style="@style/BriarButtonFlat.Negative"
|
||||||
android:layout_width="0dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/link_warning_open_link"
|
android:text="@string/link_warning_open_link"/>
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toEndOf="@+id/cancelButton"/>
|
|
||||||
|
|
||||||
</android.support.constraint.ConstraintLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -10,6 +10,12 @@
|
|||||||
android:enabled="false"
|
android:enabled="false"
|
||||||
app:showAsAction="never"/>
|
app:showAsAction="never"/>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_set_alias"
|
||||||
|
android:title="@string/set_contact_alias"
|
||||||
|
android:enabled="true"
|
||||||
|
app:showAsAction="never"/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_social_remove_person"
|
android:id="@+id/action_social_remove_person"
|
||||||
android:icon="@drawable/action_delete_white"
|
android:icon="@drawable/action_delete_white"
|
||||||
|
|||||||
@@ -127,6 +127,9 @@
|
|||||||
<string name="date_no_private_messages">No messages.</string>
|
<string name="date_no_private_messages">No messages.</string>
|
||||||
<string name="no_private_messages">No messages to show</string>
|
<string name="no_private_messages">No messages to show</string>
|
||||||
<string name="message_hint">Type message</string>
|
<string name="message_hint">Type message</string>
|
||||||
|
<string name="set_contact_alias">Set alias name</string>
|
||||||
|
<string name="set_contact_alias_hint">Contact alias</string>
|
||||||
|
<string name="set_alias">Set Alias</string>
|
||||||
<string name="delete_contact">Delete contact</string>
|
<string name="delete_contact">Delete contact</string>
|
||||||
<string name="dialog_title_delete_contact">Confirm Contact Deletion</string>
|
<string name="dialog_title_delete_contact">Confirm Contact Deletion</string>
|
||||||
<string name="dialog_message_delete_contact">Are you sure that you want to remove this contact and all messages exchanged with this contact?</string>
|
<string name="dialog_message_delete_contact">Are you sure that you want to remove this contact and all messages exchanged with this contact?</string>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ dependencyVerification {
|
|||||||
'android.arch.core:common:1.1.1:common-1.1.1.jar:3a616a32f433e9e23f556b38575c31b013613d3ae85206263b7625fe1f4c151a',
|
'android.arch.core:common:1.1.1:common-1.1.1.jar:3a616a32f433e9e23f556b38575c31b013613d3ae85206263b7625fe1f4c151a',
|
||||||
'android.arch.core:runtime:1.1.1:runtime-1.1.1.aar:c3215aa5873311b3f88a6f4e4a3c25ad89971bc127de8c3e1291c57f93a05c39',
|
'android.arch.core:runtime:1.1.1:runtime-1.1.1.aar:c3215aa5873311b3f88a6f4e4a3c25ad89971bc127de8c3e1291c57f93a05c39',
|
||||||
'android.arch.lifecycle:common:1.1.1:common-1.1.1.jar:8d378e88ebd5189e09eef623414812c868fd90aa519d6160e2311fb8b81cff56',
|
'android.arch.lifecycle:common:1.1.1:common-1.1.1.jar:8d378e88ebd5189e09eef623414812c868fd90aa519d6160e2311fb8b81cff56',
|
||||||
|
'android.arch.lifecycle:extensions:1.1.1:extensions-1.1.1.aar:429426b2feec2245ffc5e75b3b5309bedb36159cf06dc71843ae43526ac289b6',
|
||||||
'android.arch.lifecycle:livedata-core:1.1.1:livedata-core-1.1.1.aar:d6fdd8b985d6178d7ea2f16986a24e83f1bee936b74d43167c69e08d3cc12c50',
|
'android.arch.lifecycle:livedata-core:1.1.1:livedata-core-1.1.1.aar:d6fdd8b985d6178d7ea2f16986a24e83f1bee936b74d43167c69e08d3cc12c50',
|
||||||
'android.arch.lifecycle:livedata:1.1.1:livedata-1.1.1.aar:50ab0490c1ff1a7cfb4e554032998b080888946d0dd424f39900efc4a1bcd750',
|
'android.arch.lifecycle:livedata:1.1.1:livedata-1.1.1.aar:50ab0490c1ff1a7cfb4e554032998b080888946d0dd424f39900efc4a1bcd750',
|
||||||
'android.arch.lifecycle:runtime:1.1.1:runtime-1.1.1.aar:c4e4be66c1b2f0abec593571454e1de14013f7e0f96bf2a9f212931a48cae550',
|
'android.arch.lifecycle:runtime:1.1.1:runtime-1.1.1.aar:c4e4be66c1b2f0abec593571454e1de14013f7e0f96bf2a9f212931a48cae550',
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.briarproject.briar.api.introduction;
|
package org.briarproject.briar.api.introduction;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.identity.Author;
|
import org.briarproject.bramble.api.identity.Author;
|
||||||
|
import org.briarproject.bramble.api.identity.AuthorInfo;
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.sync.GroupId;
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
import org.briarproject.bramble.api.sync.MessageId;
|
import org.briarproject.bramble.api.sync.MessageId;
|
||||||
@@ -15,19 +16,24 @@ import javax.annotation.concurrent.Immutable;
|
|||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
public class IntroductionRequest extends PrivateRequest<Author> {
|
public class IntroductionRequest extends PrivateRequest<Author> {
|
||||||
|
|
||||||
private final boolean contact;
|
private final AuthorInfo authorInfo;
|
||||||
|
|
||||||
public IntroductionRequest(MessageId messageId, GroupId groupId,
|
public IntroductionRequest(MessageId messageId, GroupId groupId,
|
||||||
long time, boolean local, boolean sent, boolean seen, boolean read,
|
long time, boolean local, boolean sent, boolean seen, boolean read,
|
||||||
SessionId sessionId, Author author, @Nullable String text,
|
SessionId sessionId, Author author, @Nullable String text,
|
||||||
boolean answered, boolean contact) {
|
boolean answered, AuthorInfo authorInfo) {
|
||||||
super(messageId, groupId, time, local, sent, seen, read, sessionId,
|
super(messageId, groupId, time, local, sent, seen, read, sessionId,
|
||||||
author, text, answered);
|
author, text, answered);
|
||||||
this.contact = contact;
|
this.authorInfo = authorInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public String getAlias() {
|
||||||
|
return authorInfo.getAlias();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isContact() {
|
public boolean isContact() {
|
||||||
return contact;
|
return authorInfo.getStatus().isContact();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.briarproject.briar.api.introduction;
|
package org.briarproject.briar.api.introduction;
|
||||||
|
|
||||||
import org.briarproject.bramble.api.identity.Author;
|
import org.briarproject.bramble.api.identity.Author;
|
||||||
|
import org.briarproject.bramble.api.identity.AuthorInfo;
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.sync.GroupId;
|
import org.briarproject.bramble.api.sync.GroupId;
|
||||||
import org.briarproject.bramble.api.sync.MessageId;
|
import org.briarproject.bramble.api.sync.MessageId;
|
||||||
@@ -17,14 +18,17 @@ import static org.briarproject.briar.api.introduction.Role.INTRODUCER;
|
|||||||
public class IntroductionResponse extends PrivateResponse {
|
public class IntroductionResponse extends PrivateResponse {
|
||||||
|
|
||||||
private final Author introducedAuthor;
|
private final Author introducedAuthor;
|
||||||
|
private final AuthorInfo introducedAuthorInfo;
|
||||||
private final Role ourRole;
|
private final Role ourRole;
|
||||||
|
|
||||||
public IntroductionResponse(MessageId messageId, GroupId groupId, long time,
|
public IntroductionResponse(MessageId messageId, GroupId groupId, long time,
|
||||||
boolean local, boolean sent, boolean seen, boolean read,
|
boolean local, boolean sent, boolean seen, boolean read,
|
||||||
SessionId sessionId, boolean accepted, Author author, Role role) {
|
SessionId sessionId, boolean accepted, Author author,
|
||||||
|
AuthorInfo introducedAuthorInfo, Role role) {
|
||||||
super(messageId, groupId, time, local, sent, seen, read, sessionId,
|
super(messageId, groupId, time, local, sent, seen, read, sessionId,
|
||||||
accepted);
|
accepted);
|
||||||
this.introducedAuthor = author;
|
this.introducedAuthor = author;
|
||||||
|
this.introducedAuthorInfo = introducedAuthorInfo;
|
||||||
this.ourRole = role;
|
this.ourRole = role;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,6 +36,10 @@ public class IntroductionResponse extends PrivateResponse {
|
|||||||
return introducedAuthor;
|
return introducedAuthor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AuthorInfo getIntroducedAuthorInfo() {
|
||||||
|
return introducedAuthorInfo;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isIntroducer() {
|
public boolean isIntroducer() {
|
||||||
return ourRole == INTRODUCER;
|
return ourRole == INTRODUCER;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import org.briarproject.bramble.api.db.DbException;
|
|||||||
import org.briarproject.bramble.api.db.Transaction;
|
import org.briarproject.bramble.api.db.Transaction;
|
||||||
import org.briarproject.bramble.api.identity.Author;
|
import org.briarproject.bramble.api.identity.Author;
|
||||||
import org.briarproject.bramble.api.identity.AuthorId;
|
import org.briarproject.bramble.api.identity.AuthorId;
|
||||||
|
import org.briarproject.bramble.api.identity.AuthorInfo;
|
||||||
import org.briarproject.bramble.api.identity.IdentityManager;
|
import org.briarproject.bramble.api.identity.IdentityManager;
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.bramble.api.plugin.TransportId;
|
import org.briarproject.bramble.api.plugin.TransportId;
|
||||||
@@ -149,11 +150,13 @@ abstract class AbstractProtocolEngine<S extends Session>
|
|||||||
throws DbException {
|
throws DbException {
|
||||||
AuthorId localAuthorId = identityManager.getLocalAuthor(txn).getId();
|
AuthorId localAuthorId = identityManager.getLocalAuthor(txn).getId();
|
||||||
Contact c = contactManager.getContact(txn, sender, localAuthorId);
|
Contact c = contactManager.getContact(txn, sender, localAuthorId);
|
||||||
|
AuthorInfo otherAuthorInfo =
|
||||||
|
contactManager.getAuthorInfo(txn, otherAuthor.getId());
|
||||||
IntroductionResponse response =
|
IntroductionResponse response =
|
||||||
new IntroductionResponse(m.getMessageId(), m.getGroupId(),
|
new IntroductionResponse(m.getMessageId(), m.getGroupId(),
|
||||||
m.getTimestamp(), false, false, false, false,
|
m.getTimestamp(), false, false, false, false,
|
||||||
s.getSessionId(), m instanceof AcceptMessage,
|
s.getSessionId(), m instanceof AcceptMessage,
|
||||||
otherAuthor, s.getRole());
|
otherAuthor, otherAuthorInfo, s.getRole());
|
||||||
IntroductionResponseReceivedEvent e =
|
IntroductionResponseReceivedEvent e =
|
||||||
new IntroductionResponseReceivedEvent(response, c.getId());
|
new IntroductionResponseReceivedEvent(response, c.getId());
|
||||||
txn.attach(e);
|
txn.attach(e);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import org.briarproject.bramble.api.db.ContactExistsException;
|
|||||||
import org.briarproject.bramble.api.db.DatabaseComponent;
|
import org.briarproject.bramble.api.db.DatabaseComponent;
|
||||||
import org.briarproject.bramble.api.db.DbException;
|
import org.briarproject.bramble.api.db.DbException;
|
||||||
import org.briarproject.bramble.api.db.Transaction;
|
import org.briarproject.bramble.api.db.Transaction;
|
||||||
|
import org.briarproject.bramble.api.identity.AuthorInfo;
|
||||||
import org.briarproject.bramble.api.identity.IdentityManager;
|
import org.briarproject.bramble.api.identity.IdentityManager;
|
||||||
import org.briarproject.bramble.api.identity.LocalAuthor;
|
import org.briarproject.bramble.api.identity.LocalAuthor;
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
@@ -251,12 +252,12 @@ class IntroduceeProtocolEngine
|
|||||||
LocalAuthor localAuthor = identityManager.getLocalAuthor(txn);
|
LocalAuthor localAuthor = identityManager.getLocalAuthor(txn);
|
||||||
Contact c = contactManager.getContact(txn, s.getIntroducer().getId(),
|
Contact c = contactManager.getContact(txn, s.getIntroducer().getId(),
|
||||||
localAuthor.getId());
|
localAuthor.getId());
|
||||||
boolean contactExists = contactManager
|
AuthorInfo authorInfo =
|
||||||
.contactExists(txn, m.getAuthor().getId(), localAuthor.getId());
|
contactManager.getAuthorInfo(txn, m.getAuthor().getId());
|
||||||
IntroductionRequest request = new IntroductionRequest(m.getMessageId(),
|
IntroductionRequest request = new IntroductionRequest(m.getMessageId(),
|
||||||
m.getGroupId(), m.getTimestamp(), false, false, false, false,
|
m.getGroupId(), m.getTimestamp(), false, false, false, false,
|
||||||
s.getSessionId(), m.getAuthor(), m.getText(), false,
|
s.getSessionId(), m.getAuthor(), m.getText(), false,
|
||||||
contactExists);
|
authorInfo);
|
||||||
IntroductionRequestReceivedEvent e =
|
IntroductionRequestReceivedEvent e =
|
||||||
new IntroductionRequestReceivedEvent(request, c.getId());
|
new IntroductionRequestReceivedEvent(request, c.getId());
|
||||||
txn.attach(e);
|
txn.attach(e);
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import org.briarproject.bramble.api.db.DbException;
|
|||||||
import org.briarproject.bramble.api.db.Metadata;
|
import org.briarproject.bramble.api.db.Metadata;
|
||||||
import org.briarproject.bramble.api.db.Transaction;
|
import org.briarproject.bramble.api.db.Transaction;
|
||||||
import org.briarproject.bramble.api.identity.Author;
|
import org.briarproject.bramble.api.identity.Author;
|
||||||
|
import org.briarproject.bramble.api.identity.AuthorId;
|
||||||
|
import org.briarproject.bramble.api.identity.AuthorInfo;
|
||||||
import org.briarproject.bramble.api.identity.IdentityManager;
|
import org.briarproject.bramble.api.identity.IdentityManager;
|
||||||
import org.briarproject.bramble.api.identity.LocalAuthor;
|
import org.briarproject.bramble.api.identity.LocalAuthor;
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
@@ -39,6 +41,7 @@ import org.briarproject.briar.introduction.IntroducerSession.Introducee;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
@@ -408,6 +411,7 @@ class IntroductionManagerImpl extends ConversationClientImpl
|
|||||||
.getMessageMetadataAsDictionary(txn, contactGroupId, query);
|
.getMessageMetadataAsDictionary(txn, contactGroupId, query);
|
||||||
List<PrivateMessageHeader> messages =
|
List<PrivateMessageHeader> messages =
|
||||||
new ArrayList<>(results.size());
|
new ArrayList<>(results.size());
|
||||||
|
Map<AuthorId, AuthorInfo> authorInfos = new HashMap<>();
|
||||||
for (Entry<MessageId, BdfDictionary> e : results.entrySet()) {
|
for (Entry<MessageId, BdfDictionary> e : results.entrySet()) {
|
||||||
MessageId m = e.getKey();
|
MessageId m = e.getKey();
|
||||||
MessageMetadata meta =
|
MessageMetadata meta =
|
||||||
@@ -419,15 +423,17 @@ class IntroductionManagerImpl extends ConversationClientImpl
|
|||||||
if (type == REQUEST) {
|
if (type == REQUEST) {
|
||||||
messages.add(
|
messages.add(
|
||||||
parseInvitationRequest(txn, contactGroupId, m,
|
parseInvitationRequest(txn, contactGroupId, m,
|
||||||
meta, status, ss.bdfSession));
|
meta, status, ss.bdfSession, authorInfos));
|
||||||
} else if (type == ACCEPT) {
|
} else if (type == ACCEPT) {
|
||||||
messages.add(
|
messages.add(
|
||||||
parseInvitationResponse(contactGroupId, m, meta,
|
parseInvitationResponse(txn, contactGroupId, m,
|
||||||
status, ss.bdfSession, true));
|
meta, status, ss.bdfSession, authorInfos,
|
||||||
|
true));
|
||||||
} else if (type == DECLINE) {
|
} else if (type == DECLINE) {
|
||||||
messages.add(
|
messages.add(
|
||||||
parseInvitationResponse(contactGroupId, m, meta,
|
parseInvitationResponse(txn, contactGroupId, m,
|
||||||
status, ss.bdfSession, false));
|
meta, status, ss.bdfSession, authorInfos,
|
||||||
|
false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return messages;
|
return messages;
|
||||||
@@ -438,7 +444,8 @@ class IntroductionManagerImpl extends ConversationClientImpl
|
|||||||
|
|
||||||
private IntroductionRequest parseInvitationRequest(Transaction txn,
|
private IntroductionRequest parseInvitationRequest(Transaction txn,
|
||||||
GroupId contactGroupId, MessageId m, MessageMetadata meta,
|
GroupId contactGroupId, MessageId m, MessageMetadata meta,
|
||||||
MessageStatus status, BdfDictionary bdfSession)
|
MessageStatus status, BdfDictionary bdfSession,
|
||||||
|
Map<AuthorId, AuthorInfo> authorInfos)
|
||||||
throws DbException, FormatException {
|
throws DbException, FormatException {
|
||||||
Role role = sessionParser.getRole(bdfSession);
|
Role role = sessionParser.getRole(bdfSession);
|
||||||
SessionId sessionId;
|
SessionId sessionId;
|
||||||
@@ -462,19 +469,22 @@ class IntroductionManagerImpl extends ConversationClientImpl
|
|||||||
BdfList body = clientHelper.toList(msg);
|
BdfList body = clientHelper.toList(msg);
|
||||||
RequestMessage rm = messageParser.parseRequestMessage(msg, body);
|
RequestMessage rm = messageParser.parseRequestMessage(msg, body);
|
||||||
String text = rm.getText();
|
String text = rm.getText();
|
||||||
LocalAuthor localAuthor = identityManager.getLocalAuthor(txn);
|
AuthorInfo authorInfo = authorInfos.get(author.getId());
|
||||||
boolean contactExists = contactManager
|
if (authorInfo == null) {
|
||||||
.contactExists(txn, rm.getAuthor().getId(),
|
authorInfo = contactManager.getAuthorInfo(txn, author.getId());
|
||||||
localAuthor.getId());
|
authorInfos.put(author.getId(), authorInfo);
|
||||||
|
}
|
||||||
return new IntroductionRequest(m, contactGroupId, meta.getTimestamp(),
|
return new IntroductionRequest(m, contactGroupId, meta.getTimestamp(),
|
||||||
meta.isLocal(), status.isSent(), status.isSeen(), meta.isRead(),
|
meta.isLocal(), status.isSent(), status.isSeen(), meta.isRead(),
|
||||||
sessionId, author, text, !meta.isAvailableToAnswer(),
|
sessionId, author, text, !meta.isAvailableToAnswer(),
|
||||||
contactExists);
|
authorInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IntroductionResponse parseInvitationResponse(GroupId contactGroupId,
|
private IntroductionResponse parseInvitationResponse(Transaction txn,
|
||||||
MessageId m, MessageMetadata meta, MessageStatus status,
|
GroupId contactGroupId, MessageId m, MessageMetadata meta,
|
||||||
BdfDictionary bdfSession, boolean accept) throws FormatException {
|
MessageStatus status, BdfDictionary bdfSession,
|
||||||
|
Map<AuthorId, AuthorInfo> authorInfos, boolean accept)
|
||||||
|
throws FormatException, DbException {
|
||||||
Role role = sessionParser.getRole(bdfSession);
|
Role role = sessionParser.getRole(bdfSession);
|
||||||
SessionId sessionId;
|
SessionId sessionId;
|
||||||
Author author;
|
Author author;
|
||||||
@@ -493,9 +503,14 @@ class IntroductionManagerImpl extends ConversationClientImpl
|
|||||||
sessionId = session.getSessionId();
|
sessionId = session.getSessionId();
|
||||||
author = session.getRemote().author;
|
author = session.getRemote().author;
|
||||||
} else throw new AssertionError();
|
} else throw new AssertionError();
|
||||||
|
AuthorInfo authorInfo = authorInfos.get(author.getId());
|
||||||
|
if (authorInfo == null) {
|
||||||
|
authorInfo = contactManager.getAuthorInfo(txn, author.getId());
|
||||||
|
authorInfos.put(author.getId(), authorInfo);
|
||||||
|
}
|
||||||
return new IntroductionResponse(m, contactGroupId, meta.getTimestamp(),
|
return new IntroductionResponse(m, contactGroupId, meta.getTimestamp(),
|
||||||
meta.isLocal(), status.isSent(), status.isSeen(), meta.isRead(),
|
meta.isLocal(), status.isSent(), status.isSeen(), meta.isRead(),
|
||||||
sessionId, accept, author, role);
|
sessionId, accept, author, authorInfo, role);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeSessionWithIntroducer(Transaction txn,
|
private void removeSessionWithIntroducer(Transaction txn,
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import io.javalin.json.JavalinJson.toJson
|
|||||||
import io.mockk.*
|
import io.mockk.*
|
||||||
import org.briarproject.bramble.api.contact.ContactId
|
import org.briarproject.bramble.api.contact.ContactId
|
||||||
import org.briarproject.bramble.api.db.NoSuchContactException
|
import org.briarproject.bramble.api.db.NoSuchContactException
|
||||||
|
import org.briarproject.bramble.api.identity.AuthorInfo
|
||||||
|
import org.briarproject.bramble.api.identity.AuthorInfo.Status.UNVERIFIED
|
||||||
|
import org.briarproject.bramble.api.identity.AuthorInfo.Status.VERIFIED
|
||||||
import org.briarproject.bramble.test.ImmediateExecutor
|
import org.briarproject.bramble.test.ImmediateExecutor
|
||||||
import org.briarproject.bramble.test.TestUtils.getRandomId
|
import org.briarproject.bramble.test.TestUtils.getRandomId
|
||||||
import org.briarproject.bramble.util.StringUtils.getRandomString
|
import org.briarproject.bramble.util.StringUtils.getRandomString
|
||||||
@@ -61,7 +64,7 @@ internal class MessagingControllerImplTest : ControllerTest() {
|
|||||||
fun listIntroductionRequest() {
|
fun listIntroductionRequest() {
|
||||||
val request = IntroductionRequest(
|
val request = IntroductionRequest(
|
||||||
message.id, group.id, timestamp, true, true, false, true, sessionId, author, text,
|
message.id, group.id, timestamp, true, true, false, true, sessionId, author, text,
|
||||||
false, false
|
false, AuthorInfo(UNVERIFIED)
|
||||||
)
|
)
|
||||||
|
|
||||||
expectGetContact()
|
expectGetContact()
|
||||||
@@ -200,7 +203,7 @@ internal class MessagingControllerImplTest : ControllerTest() {
|
|||||||
fun testIntroductionRequestWithNullText() {
|
fun testIntroductionRequestWithNullText() {
|
||||||
val request = IntroductionRequest(
|
val request = IntroductionRequest(
|
||||||
message.id, group.id, timestamp, true, true, false, true, sessionId, author, null,
|
message.id, group.id, timestamp, true, true, false, true, sessionId, author, null,
|
||||||
false, false
|
false, AuthorInfo(VERIFIED)
|
||||||
)
|
)
|
||||||
val json = """
|
val json = """
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user