Include author and rating in private message headers.

This commit is contained in:
akwizgran
2013-04-14 21:15:23 +01:00
parent 4ff2b88955
commit da7657ff4d
15 changed files with 969 additions and 901 deletions

View File

@@ -118,7 +118,7 @@ implements DatabaseListener, OnClickListener, OnItemClickListener {
serviceConnection.waitForStartup();
long now = System.currentTimeMillis();
Collection<GroupMessageHeader> headers =
db.getMessageHeaders(groupId);
db.getGroupMessageHeaders(groupId);
long duration = System.currentTimeMillis() - now;
if(LOG.isLoggable(INFO))
LOG.info("Load took " + duration + " ms");

View File

@@ -129,7 +129,7 @@ implements OnClickListener, DatabaseListener, NoBlogsDialog.Listener {
boolean postable = local.contains(g.getId());
try {
Collection<GroupMessageHeader> headers =
db.getMessageHeaders(g.getId());
db.getGroupMessageHeaders(g.getId());
displayHeaders(g, postable, headers);
} catch(NoSuchSubscriptionException e) {
if(LOG.isLoggable(INFO))
@@ -256,7 +256,7 @@ implements OnClickListener, DatabaseListener, NoBlogsDialog.Listener {
serviceConnection.waitForStartup();
long now = System.currentTimeMillis();
Collection<GroupMessageHeader> headers =
db.getMessageHeaders(g.getId());
db.getGroupMessageHeaders(g.getId());
boolean postable = db.getLocalGroups().contains(g);
long duration = System.currentTimeMillis() - now;
if(LOG.isLoggable(INFO))

View File

@@ -116,7 +116,7 @@ OnClickListener, OnItemClickListener {
serviceConnection.waitForStartup();
long now = System.currentTimeMillis();
Collection<GroupMessageHeader> headers =
db.getMessageHeaders(groupId);
db.getGroupMessageHeaders(groupId);
long duration = System.currentTimeMillis() - now;
if(LOG.isLoggable(INFO))
LOG.info("Load took " + duration + " ms");

View File

@@ -124,7 +124,7 @@ implements OnClickListener, DatabaseListener, NoGroupsDialog.Listener {
if(g.isRestricted()) continue;
try {
Collection<GroupMessageHeader> headers =
db.getMessageHeaders(g.getId());
db.getGroupMessageHeaders(g.getId());
displayHeaders(g, headers);
} catch(NoSuchSubscriptionException e) {
if(LOG.isLoggable(INFO))
@@ -244,7 +244,7 @@ implements OnClickListener, DatabaseListener, NoGroupsDialog.Listener {
serviceConnection.waitForStartup();
long now = System.currentTimeMillis();
Collection<GroupMessageHeader> headers =
db.getMessageHeaders(g.getId());
db.getGroupMessageHeaders(g.getId());
long duration = System.currentTimeMillis() - now;
if(LOG.isLoggable(INFO))
LOG.info("Partial load took " + duration + " ms");

View File

@@ -19,7 +19,6 @@ import net.sf.briar.android.BriarService.BriarServiceConnection;
import net.sf.briar.android.widgets.HorizontalBorder;
import net.sf.briar.api.AuthorId;
import net.sf.briar.api.ContactId;
import net.sf.briar.api.LocalAuthor;
import net.sf.briar.api.android.DatabaseUiExecutor;
import net.sf.briar.api.db.DatabaseComponent;
import net.sf.briar.api.db.DbException;
@@ -60,7 +59,6 @@ implements DatabaseListener, OnClickListener, OnItemClickListener {
@Inject @DatabaseUiExecutor private volatile Executor dbUiExecutor;
private volatile ContactId contactId = null;
private volatile AuthorId localAuthorId = null;
private volatile String localAuthorName = null;
@Override
public void onCreate(Bundle state) {
@@ -82,7 +80,7 @@ implements DatabaseListener, OnClickListener, OnItemClickListener {
layout.setOrientation(VERTICAL);
layout.setGravity(CENTER_HORIZONTAL);
adapter = new ConversationAdapter(this, contactName);
adapter = new ConversationAdapter(this);
list = new ListView(this);
// Give me all the width and all the unused height
list.setLayoutParams(MATCH_WRAP_1);
@@ -118,14 +116,12 @@ implements DatabaseListener, OnClickListener, OnItemClickListener {
try {
serviceConnection.waitForStartup();
long now = System.currentTimeMillis();
LocalAuthor localAuthor = db.getLocalAuthor(localAuthorId);
localAuthorName = localAuthor.getName();
Collection<PrivateMessageHeader> headers =
db.getPrivateMessageHeaders(contactId);
long duration = System.currentTimeMillis() - now;
if(LOG.isLoggable(INFO))
LOG.info("Load took " + duration + " ms");
displayHeaders(localAuthor, headers);
displayHeaders(headers);
} catch(NoSuchContactException e) {
if(LOG.isLoggable(INFO)) LOG.info("Contact removed");
finishOnUiThread();
@@ -141,11 +137,10 @@ implements DatabaseListener, OnClickListener, OnItemClickListener {
});
}
private void displayHeaders(final LocalAuthor localAuthor,
private void displayHeaders(
final Collection<PrivateMessageHeader> headers) {
runOnUiThread(new Runnable() {
public void run() {
adapter.setLocalAuthorName(localAuthor.getName());
adapter.clear();
for(PrivateMessageHeader h : headers) adapter.add(h);
adapter.sort(AscendingHeaderComparator.INSTANCE);
@@ -228,7 +223,6 @@ implements DatabaseListener, OnClickListener, OnItemClickListener {
Intent i = new Intent(this, ReadPrivateMessageActivity.class);
i.putExtra("net.sf.briar.CONTACT_ID", contactId.getInt());
i.putExtra("net.sf.briar.CONTACT_NAME", contactName);
i.putExtra("net.sf.briar.LOCAL_AUTHOR_NAME", localAuthorName);
i.putExtra("net.sf.briar.MESSAGE_ID", item.getId().getBytes());
i.putExtra("net.sf.briar.CONTENT_TYPE", item.getContentType());
i.putExtra("net.sf.briar.TIMESTAMP", item.getTimestamp());

View File

@@ -23,23 +23,13 @@ import android.widget.TextView;
class ConversationAdapter extends ArrayAdapter<PrivateMessageHeader> {
private final String contactName;
private String localAuthorName = null;
ConversationAdapter(Context ctx, String contactName) {
ConversationAdapter(Context ctx) {
super(ctx, android.R.layout.simple_expandable_list_item_1,
new ArrayList<PrivateMessageHeader>());
this.contactName = contactName;
}
void setLocalAuthorName(String localAuthorName) {
this.localAuthorName = localAuthorName;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(localAuthorName == null) throw new IllegalStateException();
PrivateMessageHeader item = getItem(position);
Context ctx = getContext();
@@ -59,8 +49,7 @@ class ConversationAdapter extends ArrayAdapter<PrivateMessageHeader> {
name.setTextSize(18);
name.setMaxLines(1);
name.setPadding(10, 10, 10, 10);
if(item.isIncoming()) name.setText(contactName);
else name.setText(localAuthorName);
name.setText(item.getAuthor().getName());
innerLayout.addView(name);
if(item.getContentType().equals("text/plain")) {