mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-21 15:19:53 +01:00
Removed mark read and mark unread buttons. Bug #48.
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.9 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.7 KiB |
@@ -51,8 +51,7 @@ implements OnClickListener {
|
|||||||
|
|
||||||
private String contactName = null;
|
private String contactName = null;
|
||||||
private AuthorId localAuthorId = null;
|
private AuthorId localAuthorId = null;
|
||||||
private boolean read = false;
|
private ImageButton prevButton = null, nextButton = null;
|
||||||
private ImageButton readButton = null, prevButton = null, nextButton = null;
|
|
||||||
private ImageButton replyButton = null;
|
private ImageButton replyButton = null;
|
||||||
private TextView content = null;
|
private TextView content = null;
|
||||||
private int position = -1;
|
private int position = -1;
|
||||||
@@ -89,13 +88,6 @@ implements OnClickListener {
|
|||||||
position = i.getIntExtra("briar.POSITION", -1);
|
position = i.getIntExtra("briar.POSITION", -1);
|
||||||
if(position == -1) throw new IllegalStateException();
|
if(position == -1) throw new IllegalStateException();
|
||||||
|
|
||||||
if(state == null) {
|
|
||||||
read = false;
|
|
||||||
setReadInDatabase(true);
|
|
||||||
} else {
|
|
||||||
read = state.getBoolean("briar.READ");
|
|
||||||
}
|
|
||||||
|
|
||||||
LinearLayout layout = new LinearLayout(this);
|
LinearLayout layout = new LinearLayout(this);
|
||||||
layout.setLayoutParams(MATCH_WRAP);
|
layout.setLayoutParams(MATCH_WRAP);
|
||||||
layout.setOrientation(VERTICAL);
|
layout.setOrientation(VERTICAL);
|
||||||
@@ -143,14 +135,6 @@ implements OnClickListener {
|
|||||||
Resources res = getResources();
|
Resources res = getResources();
|
||||||
footer.setBackgroundColor(res.getColor(R.color.button_bar_background));
|
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 = new ImageButton(this);
|
||||||
prevButton.setBackgroundResource(0);
|
prevButton.setBackgroundResource(0);
|
||||||
prevButton.setImageResource(R.drawable.navigation_previous_item);
|
prevButton.setImageResource(R.drawable.navigation_previous_item);
|
||||||
@@ -175,16 +159,21 @@ implements OnClickListener {
|
|||||||
setContentView(layout);
|
setContentView(layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setReadInDatabase(final boolean read) {
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
if(isFinishing()) markMessageRead();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void markMessageRead() {
|
||||||
runOnDbThread(new Runnable() {
|
runOnDbThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
db.setReadFlag(messageId, read);
|
db.setReadFlag(messageId, true);
|
||||||
long duration = System.currentTimeMillis() - now;
|
long duration = System.currentTimeMillis() - now;
|
||||||
if(LOG.isLoggable(INFO))
|
if(LOG.isLoggable(INFO))
|
||||||
LOG.info("Setting flag took " + duration + " ms");
|
LOG.info("Marking read took " + duration + " ms");
|
||||||
setReadInUi(read);
|
|
||||||
} catch(DbException e) {
|
} catch(DbException e) {
|
||||||
if(LOG.isLoggable(WARNING))
|
if(LOG.isLoggable(WARNING))
|
||||||
LOG.log(WARNING, e.toString(), e);
|
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() {
|
private void loadMessageBody() {
|
||||||
runOnDbThread(new Runnable() {
|
runOnDbThread(new Runnable() {
|
||||||
public void run() {
|
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) {
|
public void onClick(View view) {
|
||||||
if(view == readButton) {
|
if(view == prevButton) {
|
||||||
setReadInDatabase(!read);
|
|
||||||
} else if(view == prevButton) {
|
|
||||||
Intent i = new Intent();
|
Intent i = new Intent();
|
||||||
i.putExtra("briar.POSITION", position - 1);
|
i.putExtra("briar.POSITION", position - 1);
|
||||||
setResult(RESULT_PREV_NEXT, i);
|
setResult(RESULT_PREV_NEXT, i);
|
||||||
|
|||||||
@@ -50,8 +50,7 @@ implements OnClickListener {
|
|||||||
|
|
||||||
private GroupId groupId = null;
|
private GroupId groupId = null;
|
||||||
private String groupName = null;
|
private String groupName = null;
|
||||||
private boolean read;
|
private ImageButton prevButton = null, nextButton = null;
|
||||||
private ImageButton readButton = null, prevButton = null, nextButton = null;
|
|
||||||
private ImageButton replyButton = null;
|
private ImageButton replyButton = null;
|
||||||
private TextView content = null;
|
private TextView content = null;
|
||||||
private int position = -1;
|
private int position = -1;
|
||||||
@@ -86,13 +85,6 @@ implements OnClickListener {
|
|||||||
if(s == null) throw new IllegalStateException();
|
if(s == null) throw new IllegalStateException();
|
||||||
Author.Status authorStatus = Author.Status.valueOf(s);
|
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);
|
LinearLayout layout = new LinearLayout(this);
|
||||||
layout.setLayoutParams(MATCH_WRAP);
|
layout.setLayoutParams(MATCH_WRAP);
|
||||||
layout.setOrientation(VERTICAL);
|
layout.setOrientation(VERTICAL);
|
||||||
@@ -140,14 +132,6 @@ implements OnClickListener {
|
|||||||
Resources res = getResources();
|
Resources res = getResources();
|
||||||
footer.setBackgroundColor(res.getColor(R.color.button_bar_background));
|
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 = new ImageButton(this);
|
||||||
prevButton.setBackgroundResource(0);
|
prevButton.setBackgroundResource(0);
|
||||||
prevButton.setImageResource(R.drawable.navigation_previous_item);
|
prevButton.setImageResource(R.drawable.navigation_previous_item);
|
||||||
@@ -172,16 +156,21 @@ implements OnClickListener {
|
|||||||
setContentView(layout);
|
setContentView(layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setReadInDatabase(final boolean read) {
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
if(isFinishing()) markMessageRead();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void markMessageRead() {
|
||||||
runOnDbThread(new Runnable() {
|
runOnDbThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
db.setReadFlag(messageId, read);
|
db.setReadFlag(messageId, true);
|
||||||
long duration = System.currentTimeMillis() - now;
|
long duration = System.currentTimeMillis() - now;
|
||||||
if(LOG.isLoggable(INFO))
|
if(LOG.isLoggable(INFO))
|
||||||
LOG.info("Setting flag took " + duration + " ms");
|
LOG.info("Marking read took " + duration + " ms");
|
||||||
setReadInUi(read);
|
|
||||||
} catch(DbException e) {
|
} catch(DbException e) {
|
||||||
if(LOG.isLoggable(WARNING))
|
if(LOG.isLoggable(WARNING))
|
||||||
LOG.log(WARNING, e.toString(), e);
|
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() {
|
private void loadMessageBody() {
|
||||||
runOnDbThread(new Runnable() {
|
runOnDbThread(new Runnable() {
|
||||||
public void run() {
|
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) {
|
public void onClick(View view) {
|
||||||
if(view == readButton) {
|
if(view == prevButton) {
|
||||||
setReadInDatabase(!read);
|
|
||||||
} else if(view == prevButton) {
|
|
||||||
Intent i = new Intent();
|
Intent i = new Intent();
|
||||||
i.putExtra("briar.POSITION", position - 1);
|
i.putExtra("briar.POSITION", position - 1);
|
||||||
setResult(RESULT_PREV_NEXT, i);
|
setResult(RESULT_PREV_NEXT, i);
|
||||||
|
|||||||
Reference in New Issue
Block a user