Skip to content
Snippets Groups Projects
Commit 375a597d authored by akwizgran's avatar akwizgran
Browse files

Removed mark read and mark unread buttons. Bug #48.

parent 9f341505
No related branches found
No related tags found
No related merge requests found
briar-android/res/drawable-hdpi/content_read.png

1.59 KiB

briar-android/res/drawable-hdpi/content_unread.png

1.52 KiB

briar-android/res/drawable-mdpi/content_read.png

1.39 KiB

briar-android/res/drawable-mdpi/content_unread.png

1.34 KiB

briar-android/res/drawable-xhdpi/content_read.png

1.85 KiB

briar-android/res/drawable-xhdpi/content_unread.png

1.73 KiB

......@@ -51,8 +51,7 @@ implements OnClickListener {
private String contactName = null;
private AuthorId localAuthorId = null;
private boolean read = false;
private ImageButton readButton = null, prevButton = null, nextButton = null;
private ImageButton prevButton = null, nextButton = null;
private ImageButton replyButton = null;
private TextView content = null;
private int position = -1;
......@@ -89,13 +88,6 @@ implements OnClickListener {
position = i.getIntExtra("briar.POSITION", -1);
if(position == -1) throw new IllegalStateException();
if(state == null) {
read = false;
setReadInDatabase(true);
} else {
read = state.getBoolean("briar.READ");
}
LinearLayout layout = new LinearLayout(this);
layout.setLayoutParams(MATCH_WRAP);
layout.setOrientation(VERTICAL);
......@@ -143,14 +135,6 @@ implements OnClickListener {
Resources res = getResources();
footer.setBackgroundColor(res.getColor(R.color.button_bar_background));
readButton = new ImageButton(this);
readButton.setBackgroundResource(0);
if(read) readButton.setImageResource(R.drawable.content_unread);
else readButton.setImageResource(R.drawable.content_read);
readButton.setOnClickListener(this);
footer.addView(readButton);
footer.addView(new ElasticHorizontalSpace(this));
prevButton = new ImageButton(this);
prevButton.setBackgroundResource(0);
prevButton.setImageResource(R.drawable.navigation_previous_item);
......@@ -175,16 +159,21 @@ implements OnClickListener {
setContentView(layout);
}
private void setReadInDatabase(final boolean read) {
@Override
public void onPause() {
super.onPause();
if(isFinishing()) markMessageRead();
}
private void markMessageRead() {
runOnDbThread(new Runnable() {
public void run() {
try {
long now = System.currentTimeMillis();
db.setReadFlag(messageId, read);
db.setReadFlag(messageId, true);
long duration = System.currentTimeMillis() - now;
if(LOG.isLoggable(INFO))
LOG.info("Setting flag took " + duration + " ms");
setReadInUi(read);
LOG.info("Marking read took " + duration + " ms");
} catch(DbException e) {
if(LOG.isLoggable(WARNING))
LOG.log(WARNING, e.toString(), e);
......@@ -193,16 +182,6 @@ implements OnClickListener {
});
}
private void setReadInUi(final boolean read) {
runOnUiThread(new Runnable() {
public void run() {
ReadPrivateMessageActivity.this.read = read;
if(read) readButton.setImageResource(R.drawable.content_unread);
else readButton.setImageResource(R.drawable.content_read);
}
});
}
private void loadMessageBody() {
runOnDbThread(new Runnable() {
public void run() {
......@@ -231,16 +210,8 @@ implements OnClickListener {
});
}
@Override
public void onSaveInstanceState(Bundle state) {
super.onSaveInstanceState(state);
state.putBoolean("briar.READ", read);
}
public void onClick(View view) {
if(view == readButton) {
setReadInDatabase(!read);
} else if(view == prevButton) {
if(view == prevButton) {
Intent i = new Intent();
i.putExtra("briar.POSITION", position - 1);
setResult(RESULT_PREV_NEXT, i);
......
......@@ -50,8 +50,7 @@ implements OnClickListener {
private GroupId groupId = null;
private String groupName = null;
private boolean read;
private ImageButton readButton = null, prevButton = null, nextButton = null;
private ImageButton prevButton = null, nextButton = null;
private ImageButton replyButton = null;
private TextView content = null;
private int position = -1;
......@@ -86,13 +85,6 @@ implements OnClickListener {
if(s == null) throw new IllegalStateException();
Author.Status authorStatus = Author.Status.valueOf(s);
if(state == null) {
read = false;
setReadInDatabase(true);
} else {
read = state.getBoolean("briar.READ");
}
LinearLayout layout = new LinearLayout(this);
layout.setLayoutParams(MATCH_WRAP);
layout.setOrientation(VERTICAL);
......@@ -140,14 +132,6 @@ implements OnClickListener {
Resources res = getResources();
footer.setBackgroundColor(res.getColor(R.color.button_bar_background));
readButton = new ImageButton(this);
readButton.setBackgroundResource(0);
if(read) readButton.setImageResource(R.drawable.content_unread);
else readButton.setImageResource(R.drawable.content_read);
readButton.setOnClickListener(this);
footer.addView(readButton);
footer.addView(new ElasticHorizontalSpace(this));
prevButton = new ImageButton(this);
prevButton.setBackgroundResource(0);
prevButton.setImageResource(R.drawable.navigation_previous_item);
......@@ -172,16 +156,21 @@ implements OnClickListener {
setContentView(layout);
}
private void setReadInDatabase(final boolean read) {
@Override
public void onPause() {
super.onPause();
if(isFinishing()) markMessageRead();
}
private void markMessageRead() {
runOnDbThread(new Runnable() {
public void run() {
try {
long now = System.currentTimeMillis();
db.setReadFlag(messageId, read);
db.setReadFlag(messageId, true);
long duration = System.currentTimeMillis() - now;
if(LOG.isLoggable(INFO))
LOG.info("Setting flag took " + duration + " ms");
setReadInUi(read);
LOG.info("Marking read took " + duration + " ms");
} catch(DbException e) {
if(LOG.isLoggable(WARNING))
LOG.log(WARNING, e.toString(), e);
......@@ -190,16 +179,6 @@ implements OnClickListener {
});
}
private void setReadInUi(final boolean read) {
runOnUiThread(new Runnable() {
public void run() {
ReadGroupPostActivity.this.read = read;
if(read) readButton.setImageResource(R.drawable.content_unread);
else readButton.setImageResource(R.drawable.content_read);
}
});
}
private void loadMessageBody() {
runOnDbThread(new Runnable() {
public void run() {
......@@ -228,16 +207,8 @@ implements OnClickListener {
});
}
@Override
public void onSaveInstanceState(Bundle state) {
super.onSaveInstanceState(state);
state.putBoolean("briar.READ", read);
}
public void onClick(View view) {
if(view == readButton) {
setReadInDatabase(!read);
} else if(view == prevButton) {
if(view == prevButton) {
Intent i = new Intent();
i.putExtra("briar.POSITION", position - 1);
setResult(RESULT_PREV_NEXT, i);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment