context menu for conversations. fixed #630
This commit is contained in:
parent
123036fdaa
commit
240d2d68c8
|
@ -15,6 +15,7 @@ import android.os.SystemClock;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
import android.support.v4.widget.SlidingPaneLayout;
|
import android.support.v4.widget.SlidingPaneLayout;
|
||||||
import android.support.v4.widget.SlidingPaneLayout.PanelSlideListener;
|
import android.support.v4.widget.SlidingPaneLayout.PanelSlideListener;
|
||||||
|
import android.view.ContextMenu;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
@ -73,7 +74,8 @@ public class ConversationActivity extends XmppActivity implements
|
||||||
private View mContentView;
|
private View mContentView;
|
||||||
|
|
||||||
private List<Conversation> conversationList = new ArrayList<>();
|
private List<Conversation> conversationList = new ArrayList<>();
|
||||||
private Conversation selectedConversation = null;
|
private Conversation mSelectedConversation = null;
|
||||||
|
private Conversation mSelectedConversationForContext = null;
|
||||||
private ListView listView;
|
private ListView listView;
|
||||||
private ConversationFragment mConversationFragment;
|
private ConversationFragment mConversationFragment;
|
||||||
|
|
||||||
|
@ -87,11 +89,11 @@ public class ConversationActivity extends XmppActivity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public Conversation getSelectedConversation() {
|
public Conversation getSelectedConversation() {
|
||||||
return this.selectedConversation;
|
return this.mSelectedConversation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelectedConversation(Conversation conversation) {
|
public void setSelectedConversation(Conversation conversation) {
|
||||||
this.selectedConversation = conversation;
|
this.mSelectedConversation = conversation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ListView getConversationListView() {
|
public ListView getConversationListView() {
|
||||||
|
@ -180,6 +182,7 @@ public class ConversationActivity extends XmppActivity implements
|
||||||
hideConversationsOverview();
|
hideConversationsOverview();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
registerForContextMenu(listView);
|
||||||
mContentView = findViewById(R.id.content_view_spl);
|
mContentView = findViewById(R.id.content_view_spl);
|
||||||
if (mContentView == null) {
|
if (mContentView == null) {
|
||||||
mContentView = findViewById(R.id.content_view_ll);
|
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() {
|
public void openConversation() {
|
||||||
ActionBar ab = getActionBar();
|
ActionBar ab = getActionBar();
|
||||||
if (ab != null) {
|
if (ab != null) {
|
||||||
|
@ -580,7 +619,7 @@ public class ConversationActivity extends XmppActivity implements
|
||||||
|
|
||||||
protected void muteConversationDialog(final Conversation conversation) {
|
protected void muteConversationDialog(final Conversation conversation) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
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(
|
final int[] durations = getResources().getIntArray(
|
||||||
R.array.mute_options_durations);
|
R.array.mute_options_durations);
|
||||||
builder.setItems(R.array.mute_options_descriptions,
|
builder.setItems(R.array.mute_options_descriptions,
|
||||||
|
@ -598,11 +637,8 @@ public class ConversationActivity extends XmppActivity implements
|
||||||
conversation.setMutedTill(till);
|
conversation.setMutedTill(till);
|
||||||
ConversationActivity.this.xmppConnectionService.databaseBackend
|
ConversationActivity.this.xmppConnectionService.databaseBackend
|
||||||
.updateConversation(conversation);
|
.updateConversation(conversation);
|
||||||
ConversationFragment selectedFragment = (ConversationFragment) getFragmentManager()
|
updateConversationList();
|
||||||
.findFragmentByTag("conversation");
|
ConversationActivity.this.mConversationFragment.updateMessages();
|
||||||
if (selectedFragment != null) {
|
|
||||||
selectedFragment.updateMessages();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
|
|
11
src/main/res/menu/conversations_context.xml
Normal file
11
src/main/res/menu/conversations_context.xml
Normal file
|
@ -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>
|
|
@ -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="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">Show dynamic tags</string>
|
||||||
<string name="pref_show_dynamic_tags_summary">Display read-only tags underneath contacts</string>
|
<string name="pref_show_dynamic_tags_summary">Display read-only tags underneath contacts</string>
|
||||||
|
<string name="enable_notifications">Enable notifications</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue