diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-11-18 00:07:27 +0100 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-11-18 00:07:27 +0100 |
commit | 240d2d68c8f0efb24de6b713181a25880d02828c (patch) | |
tree | d03c237618932f4417e2bff581cdd7947cbbeac5 /src | |
parent | 123036fdaaf96fb095f3b642c71eda19f024ed69 (diff) |
context menu for conversations. fixed #630
Diffstat (limited to '')
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/ConversationActivity.java | 54 | ||||
-rw-r--r-- | src/main/res/menu/conversations_context.xml | 11 | ||||
-rw-r--r-- | src/main/res/values/strings.xml | 1 |
3 files changed, 57 insertions, 9 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index 56a6bead..ad071157 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -15,6 +15,7 @@ import android.os.SystemClock; import android.provider.MediaStore; import android.support.v4.widget.SlidingPaneLayout; import android.support.v4.widget.SlidingPaneLayout.PanelSlideListener; +import android.view.ContextMenu; import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; @@ -73,7 +74,8 @@ public class ConversationActivity extends XmppActivity implements private View mContentView; private List<Conversation> conversationList = new ArrayList<>(); - private Conversation selectedConversation = null; + private Conversation mSelectedConversation = null; + private Conversation mSelectedConversationForContext = null; private ListView listView; private ConversationFragment mConversationFragment; @@ -87,11 +89,11 @@ public class ConversationActivity extends XmppActivity implements } public Conversation getSelectedConversation() { - return this.selectedConversation; + return this.mSelectedConversation; } public void setSelectedConversation(Conversation conversation) { - this.selectedConversation = conversation; + this.mSelectedConversation = conversation; } public ListView getConversationListView() { @@ -180,6 +182,7 @@ public class ConversationActivity extends XmppActivity implements hideConversationsOverview(); } }); + registerForContextMenu(listView); mContentView = findViewById(R.id.content_view_spl); if (mContentView == null) { mContentView = findViewById(R.id.content_view_ll); @@ -223,6 +226,42 @@ 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() { ActionBar ab = getActionBar(); if (ab != null) { @@ -580,7 +619,7 @@ public class ConversationActivity extends XmppActivity implements protected void muteConversationDialog(final Conversation conversation) { AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle(R.string.disable_notifications_for_this_conversation); + builder.setTitle(R.string.disable_notifications); final int[] durations = getResources().getIntArray( R.array.mute_options_durations); builder.setItems(R.array.mute_options_descriptions, @@ -598,11 +637,8 @@ public class ConversationActivity extends XmppActivity implements conversation.setMutedTill(till); ConversationActivity.this.xmppConnectionService.databaseBackend .updateConversation(conversation); - ConversationFragment selectedFragment = (ConversationFragment) getFragmentManager() - .findFragmentByTag("conversation"); - if (selectedFragment != null) { - selectedFragment.updateMessages(); - } + updateConversationList(); + ConversationActivity.this.mConversationFragment.updateMessages(); } }); builder.create().show(); diff --git a/src/main/res/menu/conversations_context.xml b/src/main/res/menu/conversations_context.xml new file mode 100644 index 00000000..28dc2a6d --- /dev/null +++ b/src/main/res/menu/conversations_context.xml @@ -0,0 +1,11 @@ +<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>
\ No newline at end of file diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index d7fc8891..6881c7f9 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -351,4 +351,5 @@ <string name="are_you_sure_verify_fingerprint">Are you sure that you want to verify your contacts OTR fingerprint?</string> <string name="pref_show_dynamic_tags">Show dynamic tags</string> <string name="pref_show_dynamic_tags_summary">Display read-only tags underneath contacts</string> + <string name="enable_notifications">Enable notifications</string> </resources> |