mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-24 17:52:17 -05:00
properly remove conversations context menu
This commit is contained in:
parent
d29c861d03
commit
ab832bcff7
@ -75,7 +75,6 @@ public class ConversationActivity extends XmppActivity implements
|
|||||||
|
|
||||||
private List<Conversation> conversationList = new ArrayList<>();
|
private List<Conversation> conversationList = new ArrayList<>();
|
||||||
private Conversation mSelectedConversation = null;
|
private Conversation mSelectedConversation = null;
|
||||||
private Conversation mSelectedConversationForContext = null;
|
|
||||||
private ListView listView;
|
private ListView listView;
|
||||||
private ConversationFragment mConversationFragment;
|
private ConversationFragment mConversationFragment;
|
||||||
|
|
||||||
@ -226,42 +225,6 @@ public class ConversationActivity extends XmppActivity implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@Override
|
|
||||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
|
|
||||||
getMenuInflater().inflate(R.menu.conversations_context, menu);
|
|
||||||
AdapterView.AdapterContextMenuInfo acmi = (AdapterView.AdapterContextMenuInfo) menuInfo;
|
|
||||||
this.mSelectedConversationForContext = this.conversationList.get(acmi.position);
|
|
||||||
menu.setHeaderTitle(this.mSelectedConversationForContext.getName());
|
|
||||||
MenuItem enableNotifications = menu.findItem(R.id.action_unmute);
|
|
||||||
MenuItem disableNotifications = menu.findItem(R.id.action_mute);
|
|
||||||
if (this.mSelectedConversationForContext.isMuted()) {
|
|
||||||
disableNotifications.setVisible(false);
|
|
||||||
} else {
|
|
||||||
enableNotifications.setVisible(false);
|
|
||||||
}
|
|
||||||
super.onCreateContextMenu(menu,v,menuInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onContextItemSelected(MenuItem item) {
|
|
||||||
switch (item.getItemId()) {
|
|
||||||
case R.id.action_archive:
|
|
||||||
endConversation(mSelectedConversationForContext);
|
|
||||||
return true;
|
|
||||||
case R.id.action_mute:
|
|
||||||
muteConversationDialog(mSelectedConversationForContext);
|
|
||||||
return true;
|
|
||||||
case R.id.action_unmute:
|
|
||||||
mSelectedConversationForContext.setMutedTill(0);
|
|
||||||
xmppConnectionService.updateConversation(mSelectedConversationForContext);
|
|
||||||
updateConversationList();
|
|
||||||
ConversationActivity.this.mConversationFragment.updateMessages();
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return super.onContextItemSelected(item);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public void openConversation() {
|
public void openConversation() {
|
||||||
ActionBar ab = getActionBar();
|
ActionBar ab = getActionBar();
|
||||||
if (ab != null) {
|
if (ab != null) {
|
||||||
@ -298,6 +261,7 @@ public class ConversationActivity extends XmppActivity implements
|
|||||||
MenuItem menuAdd = menu.findItem(R.id.action_add);
|
MenuItem menuAdd = menu.findItem(R.id.action_add);
|
||||||
MenuItem menuInviteContact = menu.findItem(R.id.action_invite);
|
MenuItem menuInviteContact = menu.findItem(R.id.action_invite);
|
||||||
MenuItem menuMute = menu.findItem(R.id.action_mute);
|
MenuItem menuMute = menu.findItem(R.id.action_mute);
|
||||||
|
MenuItem menuUnmute = menu.findItem(R.id.action_unmute);
|
||||||
|
|
||||||
if (isConversationsOverviewVisable()
|
if (isConversationsOverviewVisable()
|
||||||
&& isConversationsOverviewHideable()) {
|
&& isConversationsOverviewHideable()) {
|
||||||
@ -309,6 +273,7 @@ public class ConversationActivity extends XmppActivity implements
|
|||||||
menuAttach.setVisible(false);
|
menuAttach.setVisible(false);
|
||||||
menuClearHistory.setVisible(false);
|
menuClearHistory.setVisible(false);
|
||||||
menuMute.setVisible(false);
|
menuMute.setVisible(false);
|
||||||
|
menuUnmute.setVisible(false);
|
||||||
} else {
|
} else {
|
||||||
menuAdd.setVisible(!isConversationsOverviewHideable());
|
menuAdd.setVisible(!isConversationsOverviewHideable());
|
||||||
if (this.getSelectedConversation() != null) {
|
if (this.getSelectedConversation() != null) {
|
||||||
@ -323,6 +288,11 @@ public class ConversationActivity extends XmppActivity implements
|
|||||||
menuMucDetails.setVisible(false);
|
menuMucDetails.setVisible(false);
|
||||||
menuInviteContact.setVisible(false);
|
menuInviteContact.setVisible(false);
|
||||||
}
|
}
|
||||||
|
if (this.getSelectedConversation().isMuted()) {
|
||||||
|
menuMute.setVisible(false);
|
||||||
|
} else {
|
||||||
|
menuUnmute.setVisible(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -464,6 +434,9 @@ public class ConversationActivity extends XmppActivity implements
|
|||||||
case R.id.action_mute:
|
case R.id.action_mute:
|
||||||
muteConversationDialog(getSelectedConversation());
|
muteConversationDialog(getSelectedConversation());
|
||||||
break;
|
break;
|
||||||
|
case R.id.action_unmute:
|
||||||
|
unmuteConversation(getSelectedConversation());
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -639,11 +612,20 @@ public class ConversationActivity extends XmppActivity implements
|
|||||||
.updateConversation(conversation);
|
.updateConversation(conversation);
|
||||||
updateConversationList();
|
updateConversationList();
|
||||||
ConversationActivity.this.mConversationFragment.updateMessages();
|
ConversationActivity.this.mConversationFragment.updateMessages();
|
||||||
|
invalidateOptionsMenu();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void unmuteConversation(final Conversation conversation) {
|
||||||
|
conversation.setMutedTill(0);
|
||||||
|
this.xmppConnectionService.databaseBackend.updateConversation(conversation);
|
||||||
|
updateConversationList();
|
||||||
|
ConversationActivity.this.mConversationFragment.updateMessages();
|
||||||
|
invalidateOptionsMenu();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onKeyDown(final int keyCode, final KeyEvent event) {
|
public boolean onKeyDown(final int keyCode, final KeyEvent event) {
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||||
|
@ -525,10 +525,7 @@ public class ConversationFragment extends Fragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
conversation.setMutedTill(0);
|
activity.unmuteConversation(conversation);
|
||||||
activity.xmppConnectionService.databaseBackend
|
|
||||||
.updateConversation(conversation);
|
|
||||||
updateMessages();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (!contact.showInRoster()
|
} else if (!contact.showInRoster()
|
||||||
|
@ -49,6 +49,13 @@
|
|||||||
android:orderInCategory="70"
|
android:orderInCategory="70"
|
||||||
android:showAsAction="never"
|
android:showAsAction="never"
|
||||||
android:title="@string/disable_notifications"/>
|
android:title="@string/disable_notifications"/>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_unmute"
|
||||||
|
android:orderInCategory="71"
|
||||||
|
android:showAsAction="never"
|
||||||
|
android:title="@string/enable_notifications"/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_accounts"
|
android:id="@+id/action_accounts"
|
||||||
android:orderInCategory="90"
|
android:orderInCategory="90"
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
|
||||||
<item
|
|
||||||
android:id="@+id/action_archive"
|
|
||||||
android:title="@string/action_end_conversation"/>
|
|
||||||
<item
|
|
||||||
android:id="@+id/action_mute"
|
|
||||||
android:title="@string/disable_notifications"/>
|
|
||||||
<item
|
|
||||||
android:id="@+id/action_unmute"
|
|
||||||
android:title="@string/enable_notifications"/>
|
|
||||||
</menu>
|
|
Loading…
Reference in New Issue
Block a user