Previous message and next message buttons.

This commit is contained in:
akwizgran
2013-03-05 15:02:21 +00:00
parent 86925ef402
commit c83b1b74e5
11 changed files with 75 additions and 26 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -70,7 +70,7 @@ implements OnClickListener, DatabaseListener, ConnectionListener {
layout.addView(list); layout.addView(list);
ImageButton addContactButton = new ImageButton(this); ImageButton addContactButton = new ImageButton(this);
addContactButton.setPadding(5, 5, 5, 5); addContactButton.setPadding(10, 10, 10, 10);
addContactButton.setBackgroundResource(0); addContactButton.setBackgroundResource(0);
addContactButton.setImageResource(R.drawable.social_add_person); addContactButton.setImageResource(R.drawable.social_add_person);
addContactButton.setOnClickListener(this); addContactButton.setOnClickListener(this);

View File

@@ -82,7 +82,7 @@ implements DatabaseListener, OnClickListener, OnItemClickListener {
layout.addView(list); layout.addView(list);
ImageButton composeButton = new ImageButton(this); ImageButton composeButton = new ImageButton(this);
composeButton.setPadding(5, 5, 5, 5); composeButton.setPadding(10, 10, 10, 10);
composeButton.setBackgroundResource(0); composeButton.setBackgroundResource(0);
composeButton.setImageResource(R.drawable.content_new_email); composeButton.setImageResource(R.drawable.content_new_email);
composeButton.setOnClickListener(this); composeButton.setOnClickListener(this);
@@ -174,6 +174,10 @@ implements DatabaseListener, OnClickListener, OnItemClickListener {
public void onItemClick(AdapterView<?> parent, View view, int position, public void onItemClick(AdapterView<?> parent, View view, int position,
long id) { long id) {
showMessage(position);
}
private void showMessage(int position) {
PrivateMessageHeader item = adapter.getItem(position); PrivateMessageHeader item = adapter.getItem(position);
Intent i = new Intent(this, ReadMessageActivity.class); Intent i = new Intent(this, ReadMessageActivity.class);
i.putExtra("net.sf.briar.CONTACT_ID", contactId.getInt()); i.putExtra("net.sf.briar.CONTACT_ID", contactId.getInt());
@@ -181,7 +185,22 @@ implements DatabaseListener, OnClickListener, OnItemClickListener {
i.putExtra("net.sf.briar.MESSAGE_ID", item.getId().getBytes()); i.putExtra("net.sf.briar.MESSAGE_ID", item.getId().getBytes());
i.putExtra("net.sf.briar.CONTENT_TYPE", item.getContentType()); i.putExtra("net.sf.briar.CONTENT_TYPE", item.getContentType());
i.putExtra("net.sf.briar.TIMESTAMP", item.getTimestamp()); i.putExtra("net.sf.briar.TIMESTAMP", item.getTimestamp());
i.putExtra("net.sf.briar.FIRST", position == 0);
i.putExtra("net.sf.briar.LAST", position == adapter.getCount() - 1);
i.putExtra("net.sf.briar.STARRED", item.isStarred()); i.putExtra("net.sf.briar.STARRED", item.isStarred());
startActivity(i); startActivityForResult(i, position);
}
@Override
public void onActivityResult(int request, int result, Intent data) {
if(result == ReadMessageActivity.RESULT_PREV) {
int position = request - 1;
if(position >= 0 && position < adapter.getCount())
showMessage(position);
} else if(result == ReadMessageActivity.RESULT_NEXT) {
int position = request + 1;
if(position >= 0 && position < adapter.getCount())
showMessage(position);
}
} }
} }

View File

@@ -76,7 +76,7 @@ implements OnClickListener, DatabaseListener {
layout.addView(list); layout.addView(list);
ImageButton composeButton = new ImageButton(this); ImageButton composeButton = new ImageButton(this);
composeButton.setPadding(5, 5, 5, 5); composeButton.setPadding(10, 10, 10, 10);
composeButton.setBackgroundResource(0); composeButton.setBackgroundResource(0);
composeButton.setImageResource(R.drawable.content_new_email); composeButton.setImageResource(R.drawable.content_new_email);
composeButton.setOnClickListener(this); composeButton.setOnClickListener(this);

View File

@@ -40,6 +40,10 @@ import com.google.inject.Inject;
public class ReadMessageActivity extends BriarActivity public class ReadMessageActivity extends BriarActivity
implements OnClickListener { implements OnClickListener {
static final int RESULT_REPLY = RESULT_FIRST_USER;
static final int RESULT_PREV = RESULT_FIRST_USER + 1;
static final int RESULT_NEXT = RESULT_FIRST_USER + 2;
private static final Logger LOG = private static final Logger LOG =
Logger.getLogger(ReadMessageActivity.class.getName()); Logger.getLogger(ReadMessageActivity.class.getName());
@@ -53,9 +57,10 @@ implements OnClickListener {
private ContactId contactId = null; private ContactId contactId = null;
private String contactName = null; private String contactName = null;
private MessageId messageId = null; private MessageId messageId = null;
private boolean starred, read; private boolean first, last, starred, read;
private ImageButton replyButton = null, starButton = null; private ImageButton starButton = null, readButton = null;
private ImageButton readButton = null; private ImageButton prevButton = null, nextButton = null;
private ImageButton replyButton = null;
private TextView content = null; private TextView content = null;
@Override @Override
@@ -75,6 +80,8 @@ implements OnClickListener {
if(contentType == null) throw new IllegalStateException(); if(contentType == null) throw new IllegalStateException();
long timestamp = i.getLongExtra("net.sf.briar.TIMESTAMP", -1); long timestamp = i.getLongExtra("net.sf.briar.TIMESTAMP", -1);
if(timestamp == -1) throw new IllegalStateException(); if(timestamp == -1) throw new IllegalStateException();
first = i.getBooleanExtra("net.sf.briar.FIRST", false);
last = i.getBooleanExtra("net.sf.briar.LAST", false);
if(state != null && bundleEncrypter.decrypt(state)) { if(state != null && bundleEncrypter.decrypt(state)) {
starred = state.getBoolean("net.sf.briar.STARRED"); starred = state.getBoolean("net.sf.briar.STARRED");
@@ -154,16 +161,8 @@ implements OnClickListener {
footer.setOrientation(HORIZONTAL); footer.setOrientation(HORIZONTAL);
footer.setGravity(CENTER); footer.setGravity(CENTER);
replyButton = new ImageButton(this);
replyButton.setPadding(5, 5, 5, 5);
replyButton.setBackgroundResource(0);
replyButton.setImageResource(R.drawable.social_reply);
replyButton.setOnClickListener(this);
footer.addView(replyButton);
layout.addView(footer);
starButton = new ImageButton(this); starButton = new ImageButton(this);
starButton.setPadding(5, 5, 5, 5); starButton.setPadding(10, 10, 10, 10);
starButton.setBackgroundResource(0); starButton.setBackgroundResource(0);
if(starred) starButton.setImageResource(R.drawable.rating_important); if(starred) starButton.setImageResource(R.drawable.rating_important);
else starButton.setImageResource(R.drawable.rating_not_important); else starButton.setImageResource(R.drawable.rating_not_important);
@@ -171,13 +170,37 @@ implements OnClickListener {
footer.addView(starButton); footer.addView(starButton);
readButton = new ImageButton(this); readButton = new ImageButton(this);
readButton.setPadding(5, 5, 5, 5); readButton.setPadding(10, 10, 10, 10);
readButton.setBackgroundResource(0); readButton.setBackgroundResource(0);
if(read) readButton.setImageResource(R.drawable.content_unread); if(read) readButton.setImageResource(R.drawable.content_unread);
else readButton.setImageResource(R.drawable.content_read); else readButton.setImageResource(R.drawable.content_read);
readButton.setOnClickListener(this); readButton.setOnClickListener(this);
footer.addView(readButton); footer.addView(readButton);
prevButton = new ImageButton(this);
prevButton.setPadding(10, 10, 10, 10);
prevButton.setBackgroundResource(0);
prevButton.setImageResource(R.drawable.navigation_previous_item);
prevButton.setOnClickListener(this);
prevButton.setEnabled(!first);
footer.addView(prevButton);
nextButton = new ImageButton(this);
nextButton.setPadding(10, 10, 10, 10);
nextButton.setBackgroundResource(0);
nextButton.setImageResource(R.drawable.navigation_next_item);
nextButton.setOnClickListener(this);
nextButton.setEnabled(!last);
footer.addView(nextButton);
replyButton = new ImageButton(this);
replyButton.setPadding(10, 10, 10, 10);
replyButton.setBackgroundResource(0);
replyButton.setImageResource(R.drawable.social_reply);
replyButton.setOnClickListener(this);
footer.addView(replyButton);
layout.addView(footer);
setContentView(layout); setContentView(layout);
// Bind to the service so we can wait for the DB to be opened // Bind to the service so we can wait for the DB to be opened
@@ -227,14 +250,7 @@ implements OnClickListener {
} }
public void onClick(View view) { public void onClick(View view) {
if(view == replyButton) { if(view == starButton) {
Intent i = new Intent(this, WriteMessageActivity.class);
i.putExtra("net.sf.briar.CONTACT_ID", contactId.getInt());
i.putExtra("net.sf.briar.CONTACT_NAME", contactName);
i.putExtra("net.sf.briar.PARENT_ID", messageId.getBytes());
startActivity(i);
finish();
} else if(view == starButton) {
final MessageId messageId = this.messageId; final MessageId messageId = this.messageId;
final boolean starred = !this.starred; final boolean starred = !this.starred;
dbExecutor.execute(new Runnable() { dbExecutor.execute(new Runnable() {
@@ -280,6 +296,20 @@ implements OnClickListener {
} }
} }
}); });
} else if(view == prevButton) {
setResult(RESULT_PREV);
finish();
} else if(view == nextButton) {
setResult(RESULT_NEXT);
finish();
} else if(view == replyButton) {
Intent i = new Intent(this, WriteMessageActivity.class);
i.putExtra("net.sf.briar.CONTACT_ID", contactId.getInt());
i.putExtra("net.sf.briar.CONTACT_NAME", contactName);
i.putExtra("net.sf.briar.PARENT_ID", messageId.getBytes());
startActivity(i);
setResult(RESULT_REPLY);
finish();
} }
} }

View File

@@ -89,7 +89,7 @@ implements OnClickListener {
actionBar.addView(to); actionBar.addView(to);
ImageButton sendButton = new ImageButton(this); ImageButton sendButton = new ImageButton(this);
sendButton.setPadding(5, 5, 5, 5); sendButton.setPadding(10, 10, 10, 10);
sendButton.setBackgroundResource(0); sendButton.setBackgroundResource(0);
sendButton.setImageResource(R.drawable.social_send_now); sendButton.setImageResource(R.drawable.social_send_now);
sendButton.setOnClickListener(this); sendButton.setOnClickListener(this);