Add block/unblock to contact details menu

See #889
This commit is contained in:
Sam Whited 2015-01-15 19:08:12 -05:00 committed by iNPUTmice
parent 818c0e609c
commit 764ef3c8cd
4 changed files with 28 additions and 9 deletions

View File

@ -201,7 +201,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
@Override @Override
public boolean onOptionsItemSelected(final MenuItem menuItem) { public boolean onOptionsItemSelected(final MenuItem menuItem) {
AlertDialog.Builder builder = new AlertDialog.Builder(this); final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setNegativeButton(getString(R.string.cancel), null); builder.setNegativeButton(getString(R.string.cancel), null);
switch (menuItem.getItemId()) { switch (menuItem.getItemId()) {
case android.R.id.home: case android.R.id.home:
@ -237,13 +237,25 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
startActivity(intent); startActivity(intent);
} }
break; break;
case R.id.action_block:
BlockContactDialog.show(this, xmppConnectionService, contact);
break;
case R.id.action_unblock:
BlockContactDialog.show(this, xmppConnectionService, contact);
break;
} }
return super.onOptionsItemSelected(menuItem); return super.onOptionsItemSelected(menuItem);
} }
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.contact_details, menu); getMenuInflater().inflate(R.menu.contact_details, menu);
if (this.contact.isBlocked()) {
menu.findItem(R.id.action_block).setVisible(false);
} else {
menu.findItem(R.id.action_unblock).setVisible(false);
}
return true; return true;
} }
@ -424,6 +436,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
@Override @Override
public void run() { public void run() {
invalidateOptionsMenu();
populateView(); populateView();
} }
}); });

View File

@ -1075,10 +1075,6 @@ public class ConversationActivity extends XmppActivity
xmppConnectionService.sendUnblockRequest(conversation); xmppConnectionService.sendUnblockRequest(conversation);
} }
public void blockConversation(final Blockable conversation) {
xmppConnectionService.sendBlockRequest(conversation);
}
public boolean enterIsSend() { public boolean enterIsSend() {
return getPreferences().getBoolean("enter_is_send",false); return getPreferences().getBoolean("enter_is_send",false);
} }

View File

@ -974,7 +974,4 @@ public class ConversationFragment extends Fragment {
this.mEditMessage.append(text); this.mEditMessage.append(text);
} }
public void clearInputField() {
this.mEditMessage.setText("");
}
} }

View File

@ -17,6 +17,19 @@
android:id="@+id/action_show_qr_code" android:id="@+id/action_show_qr_code"
android:title="@string/show_qr_code" android:title="@string/show_qr_code"
android:showAsAction="never" /> android:showAsAction="never" />
<item
android:id="@+id/action_block"
android:orderInCategory="72"
android:showAsAction="never"
android:title="@string/action_block_contact"/>
<item
android:id="@+id/action_unblock"
android:orderInCategory="73"
android:showAsAction="never"
android:title="@string/action_unblock_contact"/>
<item <item
android:id="@+id/action_accounts" android:id="@+id/action_accounts"
android:orderInCategory="90" android:orderInCategory="90"