diff --git a/briar-android/res/drawable-hdpi/content_read.png b/briar-android/res/drawable-hdpi/content_read.png deleted file mode 100644 index 5fc1132225399d9dd7dc9511295b7d923cfad0c7..0000000000000000000000000000000000000000 Binary files a/briar-android/res/drawable-hdpi/content_read.png and /dev/null differ diff --git a/briar-android/res/drawable-hdpi/content_unread.png b/briar-android/res/drawable-hdpi/content_unread.png deleted file mode 100644 index e5f368257d32b4b7be5d2a2cb6fccc9643783a5e..0000000000000000000000000000000000000000 Binary files a/briar-android/res/drawable-hdpi/content_unread.png and /dev/null differ diff --git a/briar-android/res/drawable-mdpi/content_read.png b/briar-android/res/drawable-mdpi/content_read.png deleted file mode 100644 index 3d61dc5e35867d190dd452c5b86910a8ce349890..0000000000000000000000000000000000000000 Binary files a/briar-android/res/drawable-mdpi/content_read.png and /dev/null differ diff --git a/briar-android/res/drawable-mdpi/content_unread.png b/briar-android/res/drawable-mdpi/content_unread.png deleted file mode 100644 index 72956c4456bea7d7e6c678b30ebf1304ea9795b6..0000000000000000000000000000000000000000 Binary files a/briar-android/res/drawable-mdpi/content_unread.png and /dev/null differ diff --git a/briar-android/res/drawable-xhdpi/content_read.png b/briar-android/res/drawable-xhdpi/content_read.png deleted file mode 100644 index 99a826a8d43aad459ddff4f7fd496a022493b0a1..0000000000000000000000000000000000000000 Binary files a/briar-android/res/drawable-xhdpi/content_read.png and /dev/null differ diff --git a/briar-android/res/drawable-xhdpi/content_unread.png b/briar-android/res/drawable-xhdpi/content_unread.png deleted file mode 100644 index 2e4ddddbd1f576701b7bcebb959c6142a487bbc6..0000000000000000000000000000000000000000 Binary files a/briar-android/res/drawable-xhdpi/content_unread.png and /dev/null differ diff --git a/briar-android/src/org/briarproject/android/contact/ReadPrivateMessageActivity.java b/briar-android/src/org/briarproject/android/contact/ReadPrivateMessageActivity.java index cf0d43bc14392d2296a96217d031debbb5a369dc..19eeba26e43e35b7c70509e19eb8416e6a792a7a 100644 --- a/briar-android/src/org/briarproject/android/contact/ReadPrivateMessageActivity.java +++ b/briar-android/src/org/briarproject/android/contact/ReadPrivateMessageActivity.java @@ -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); diff --git a/briar-android/src/org/briarproject/android/groups/ReadGroupPostActivity.java b/briar-android/src/org/briarproject/android/groups/ReadGroupPostActivity.java index a2d11da5532b9544d855a5caba2010a9c766c6f3..5ebfb1aa50eb68348fcdbac69abcc68ad292a323 100644 --- a/briar-android/src/org/briarproject/android/groups/ReadGroupPostActivity.java +++ b/briar-android/src/org/briarproject/android/groups/ReadGroupPostActivity.java @@ -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);