aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrianBlade <n.gelbertz@gmail.com>2015-04-05 14:53:42 +0200
committerBrianBlade <n.gelbertz@gmail.com>2015-04-05 15:43:41 +0200
commit5d3b884cdb8ea72303e1bf7b03afe6fb9fc4dc70 (patch)
tree456bf730154ee2003850a6ba330a51b67f729580
parent09aae952e89f7d522a7bb0d192e2ba4a49aea79d (diff)
Fix undo(), rename blacklistedConversation
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationActivity.java36
-rw-r--r--src/main/res/values-v21/dimens.xml4
2 files changed, 28 insertions, 12 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
index 5f963da1..69e90cc1 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
@@ -76,7 +76,7 @@ public class ConversationActivity extends XmppActivity
private View mContentView;
private List<Conversation> conversationList = new ArrayList<>();
- private Conversation blacklistedConversation = null;
+ private Conversation swipedConversation = null;
private Conversation mSelectedConversation = null;
private EnhancedListView listView;
private ConversationFragment mConversationFragment;
@@ -115,6 +115,7 @@ public class ConversationActivity extends XmppActivity
public void hideConversationsOverview() {
if (mContentView instanceof SlidingPaneLayout) {
+ listView.discardUndo();
SlidingPaneLayout mSlidingPaneLayout = (SlidingPaneLayout) mContentView;
mSlidingPaneLayout.closePane();
}
@@ -184,16 +185,16 @@ public class ConversationActivity extends XmppActivity
@Override
public EnhancedListView.Undoable onDismiss(EnhancedListView enhancedListView, final int position) {
- final Conversation item = listAdapter.getItem(position);
- listAdapter.remove(item);
+ swipedConversation = listAdapter.getItem(position);
+ listAdapter.remove(swipedConversation);
listAdapter.notifyDataSetChanged();
- blacklistedConversation = item;
+ swipedConversation.markRead();
if (position == 0 && listAdapter.getCount() == 0) {
- endConversation(item, false, true);
+ endConversation(swipedConversation, false, true);
return null;
}
- else if (getSelectedConversation() == item) {
+ else if (getSelectedConversation() == swipedConversation) {
setSelectedConversation(listAdapter.getItem(0));
ConversationActivity.this.mConversationFragment
.reInit(getSelectedConversation());
@@ -202,20 +203,25 @@ public class ConversationActivity extends XmppActivity
return new EnhancedListView.Undoable() {
@Override
public void undo() {
- listAdapter.insert(item, position);
+ listAdapter.insert(swipedConversation, position);
listAdapter.notifyDataSetChanged();
- blacklistedConversation = null;
+ swipedConversation = null;
}
@Override
public void discard() {
- endConversation(item, false, false);
- blacklistedConversation = null;
+ if (!swipedConversation.isRead()
+ && swipedConversation.getMode() == Conversation.MODE_SINGLE) {
+ swipedConversation = null;
+ return;
+ }
+ endConversation(swipedConversation, false, false);
+ swipedConversation = null;
}
@Override
public String getTitle() {
- if (item.getMode() == Conversation.MODE_MULTI) {
+ if (swipedConversation.getMode() == Conversation.MODE_MULTI) {
return getResources().getString(R.string.title_undo_swipe_out_muc);
} else {
return getResources().getString(R.string.title_undo_swipe_out_conversation);
@@ -1074,6 +1080,13 @@ public class ConversationActivity extends XmppActivity
public void updateConversationList() {
xmppConnectionService
.populateWithOrderedConversations(conversationList);
+ if (swipedConversation != null) {
+ if (swipedConversation.isRead()) {
+ conversationList.remove(swipedConversation);
+ } else {
+ listView.discardUndo();
+ }
+ }
listAdapter.notifyDataSetChanged();
}
@@ -1124,7 +1137,6 @@ public class ConversationActivity extends XmppActivity
@Override
protected void refreshUiReal() {
updateConversationList();
- conversationList.remove(blacklistedConversation);
if (xmppConnectionService != null && xmppConnectionService.getAccounts().size() == 0) {
if (!mRedirected) {
this.mRedirected = true;
diff --git a/src/main/res/values-v21/dimens.xml b/src/main/res/values-v21/dimens.xml
new file mode 100644
index 00000000..8bc8f3f7
--- /dev/null
+++ b/src/main/res/values-v21/dimens.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <dimen name="elv_undo_bottom_offset">63dp</dimen> <!-- 48dp + 15dp -->
+</resources> \ No newline at end of file