diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-04-25 22:36:18 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-04-25 22:36:18 +0200 |
commit | 27fed7a6caaa7fedda9d8f40584a3839e56fc306 (patch) | |
tree | 3150f809b0e83a7a587654cc38997266f1972e74 /src/main | |
parent | ebaa9dcfab701117ff6b0e13979ee46b941c4607 (diff) |
add some more buttons to ConferenceDetailsActivity and bug fixes
* add to/remove from contact list
* leave room
Diffstat (limited to '')
4 files changed, 89 insertions, 67 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java index 5bf458a49..72c9a811f 100644 --- a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java @@ -64,26 +64,6 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers inviteToConversation(mConversation); } }; - private OnClickListener destroyListener = new OnClickListener() { - - @Override - public void onClick(View v) { - final AlertDialog.Builder DestroyMucDialog = new AlertDialog.Builder(ConferenceDetailsActivity.this); - DestroyMucDialog.setNegativeButton(getString(R.string.cancel), null); - DestroyMucDialog.setTitle(getString(R.string.destroy_muc)); - DestroyMucDialog.setMessage(getString(R.string.destroy_muc_text, mConversation.getName())); - DestroyMucDialog.setPositiveButton(getString(R.string.delete), (dialogInterface, i) -> { - Intent intent = new Intent(xmppConnectionService, ConversationsActivity.class); - intent.setAction(ConversationsActivity.ACTION_DESTROY_MUC); - intent.putExtra("MUC_UUID", mConversation.getUuid()); - Log.d(Config.LOGTAG, "Sending DESTROY intent for " + mConversation.getName()); - startActivity(intent); - deleteBookmark(); - finish(); - }); - DestroyMucDialog.create().show(); - } - }; private ActivityMucDetailsBinding binding; private String uuid = null; @@ -277,8 +257,8 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers this.binding.invite.setVisibility(View.GONE); this.binding.invite.setOnClickListener(inviteListener); this.binding.destroy.setVisibility(View.GONE); - this.binding.destroy.setOnClickListener(destroyListener); - this.binding.destroy.getBackground().setColorFilter(getWarningButtonColor(), PorterDuff.Mode.MULTIPLY); + this.binding.leaveMuc.setVisibility(View.GONE); + this.binding.addContactButton.setVisibility(View.GONE); this.binding.mucMoreDetails.setVisibility(View.GONE); setSupportActionBar((Toolbar) binding.toolbar); configureActionBar(getSupportActionBar()); @@ -328,12 +308,6 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers case R.id.action_share_uri: shareLink(false); break; - case R.id.action_save_as_bookmark: - saveAsBookmark(); - break; - case R.id.action_delete_bookmark: - deleteBookmark(); - break; case R.id.action_advanced_mode: this.mAdvancedMode = !menuItem.isChecked(); menuItem.setChecked(this.mAdvancedMode); @@ -362,21 +336,12 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers @Override public boolean onPrepareOptionsMenu(Menu menu) { - MenuItem menuItemSaveBookmark = menu.findItem(R.id.action_save_as_bookmark); - MenuItem menuItemDeleteBookmark = menu.findItem(R.id.action_delete_bookmark); MenuItem menuItemAdvancedMode = menu.findItem(R.id.action_advanced_mode); MenuItem menuItemChangeSubject = menu.findItem(R.id.action_edit_subject); menuItemAdvancedMode.setChecked(mAdvancedMode); if (mConversation == null) { return true; } - if (mConversation.getBookmark() != null) { - menuItemSaveBookmark.setVisible(false); - menuItemDeleteBookmark.setVisible(true); - } else { - menuItemDeleteBookmark.setVisible(false); - menuItemSaveBookmark.setVisible(true); - } menuItemChangeSubject.setVisible(mConversation.getMucOptions().canChangeSubject()); return true; } @@ -533,6 +498,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers protected void saveAsBookmark() { xmppConnectionService.saveConversationAsBookmark(mConversation, mConversation.getMucOptions().getSubject()); + updateView(); } protected void deleteBookmark() { @@ -563,6 +529,9 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers private void updateView() { invalidateOptionsMenu(); + if (mConversation == null) { + return; + } final MucOptions mucOptions = mConversation.getMucOptions(); final User self = mucOptions.getSelf(); String account; @@ -619,11 +588,64 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers } if (self.getAffiliation().ranks(MucOptions.Affiliation.OWNER)) { this.binding.destroy.setVisibility(View.VISIBLE); + this.binding.destroy.setOnClickListener(v -> { + final AlertDialog.Builder DestroyMucDialog = new AlertDialog.Builder(ConferenceDetailsActivity.this); + DestroyMucDialog.setNegativeButton(getString(R.string.cancel), null); + DestroyMucDialog.setTitle(getString(R.string.destroy_muc)); + DestroyMucDialog.setMessage(getString(R.string.destroy_muc_text, mConversation.getName())); + DestroyMucDialog.setPositiveButton(getString(R.string.delete), (dialogInterface, i) -> { + Intent intent = new Intent(xmppConnectionService, ConversationsActivity.class); + intent.setAction(ConversationsActivity.ACTION_DESTROY_MUC); + intent.putExtra("MUC_UUID", mConversation.getUuid()); + Log.d(Config.LOGTAG, "Sending DESTROY intent for " + mConversation.getName()); + startActivity(intent); + deleteBookmark(); + finish(); + }); + }); + this.binding.destroy.getBackground().setColorFilter(getWarningButtonColor(), PorterDuff.Mode.MULTIPLY); this.binding.changeConferenceButton.setVisibility(View.VISIBLE); } else { this.binding.destroy.setVisibility(View.GONE); this.binding.changeConferenceButton.setVisibility(View.GONE); } + this.binding.leaveMuc.setVisibility(View.VISIBLE); + this.binding.leaveMuc.setOnClickListener(v1 -> { + final AlertDialog.Builder LeaveMucDialog = new AlertDialog.Builder(ConferenceDetailsActivity.this); + LeaveMucDialog.setTitle(getString(R.string.action_end_conversation_muc)); + LeaveMucDialog.setMessage(getString(R.string.leave_conference_warning)); + LeaveMucDialog.setNegativeButton(getString(R.string.cancel), null); + LeaveMucDialog.setPositiveButton(getString(R.string.action_end_conversation_muc), + (dialog, which) -> { + startActivity(new Intent(xmppConnectionService, ConversationsActivity.class)); + this.xmppConnectionService.archiveConversation(mConversation); + finish(); + }); + LeaveMucDialog.create().show(); + }); + this.binding.leaveMuc.getBackground().setColorFilter(getWarningButtonColor(), PorterDuff.Mode.MULTIPLY); + this.binding.addContactButton.setVisibility(View.VISIBLE); + if (mConversation.getBookmark() != null) { + this.binding.addContactButton.setText(R.string.delete_bookmark); + this.binding.addContactButton.getBackground().setColorFilter(getWarningButtonColor(), PorterDuff.Mode.MULTIPLY); + this.binding.addContactButton.setOnClickListener(v2 -> { + final AlertDialog.Builder deleteFromRosterDialog = new AlertDialog.Builder(ConferenceDetailsActivity.this); + deleteFromRosterDialog.setNegativeButton(getString(R.string.cancel), null); + deleteFromRosterDialog.setTitle(getString(R.string.action_delete_contact)); + deleteFromRosterDialog.setMessage(getString(R.string.remove_bookmark_text, mConversation.getJid().toString())); + deleteFromRosterDialog.setPositiveButton(getString(R.string.delete), + (dialog, which) -> { + deleteBookmark(); + }); + deleteFromRosterDialog.create().show(); + }); + } else { + this.binding.addContactButton.setText(R.string.save_as_bookmark); + this.binding.addContactButton.getBackground().clearColorFilter(); + this.binding.addContactButton.setOnClickListener(v2 -> { + saveAsBookmark(); + }); + } } else { this.binding.mucMoreDetails.setVisibility(View.GONE); this.binding.mucInfoMore.setVisibility(View.GONE); diff --git a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java index a42e3a8c0..0c2d1bb1d 100644 --- a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java @@ -406,18 +406,12 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp binding.detailsSendPresence.setOnCheckedChangeListener(null); binding.detailsReceivePresence.setOnCheckedChangeListener(null); - final AlertDialog.Builder deleteFromRosterDialog = new AlertDialog.Builder(ContactDetailsActivity.this); - binding.addContactButton.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View view) { - deleteFromRosterDialog.setNegativeButton(getString(R.string.cancel), null); - deleteFromRosterDialog.setTitle(getString(R.string.action_delete_contact)) - .setMessage( - getString(R.string.remove_contact_text, - contact.getJid().toString())) - .setPositiveButton(getString(R.string.delete), - removeFromRoster).create().show(); - } + binding.addContactButton.setOnClickListener(view -> { + final AlertDialog.Builder deleteFromRosterDialog = new AlertDialog.Builder(ContactDetailsActivity.this); + deleteFromRosterDialog.setNegativeButton(getString(R.string.cancel), null); + deleteFromRosterDialog.setTitle(getString(R.string.action_delete_contact)); + deleteFromRosterDialog.setMessage(getString(R.string.remove_contact_text, contact.getJid().toString())); + deleteFromRosterDialog.setPositiveButton(getString(R.string.delete), removeFromRoster).create().show(); }); binding.detailsSendPresence.setOnCheckedChangeListener(null); binding.detailsReceivePresence.setOnCheckedChangeListener(null); diff --git a/src/main/res/layout/activity_muc_details.xml b/src/main/res/layout/activity_muc_details.xml index 3e1c41ff7..d5da934ba 100644 --- a/src/main/res/layout/activity_muc_details.xml +++ b/src/main/res/layout/activity_muc_details.xml @@ -215,6 +215,24 @@ android:text="@string/invite_contact" /> <Button + android:id="@+id/leave_muc" + style="?android:attr/buttonStyleSmall" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:layout_marginTop="24dp" + android:text="@string/action_end_conversation_muc" /> + + <Button + android:id="@+id/add_contact_button" + style="?android:attr/buttonStyleSmall" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:layout_marginTop="24dp" + android:text="@string/add_to_contact_list" /> + + <Button android:id="@+id/destroy" style="?android:attr/buttonStyleSmall" android:layout_width="wrap_content" diff --git a/src/main/res/menu/muc_details.xml b/src/main/res/menu/muc_details.xml index 910c986ec..f0336bdce 100644 --- a/src/main/res/menu/muc_details.xml +++ b/src/main/res/menu/muc_details.xml @@ -6,14 +6,14 @@ android:id="@+id/action_edit_subject" android:icon="?attr/icon_edit" android:orderInCategory="10" - app:showAsAction="always" - android:title="@string/action_edit_subject" /> + android:title="@string/action_edit_subject" + app:showAsAction="always" /> <item android:id="@+id/action_share" android:icon="?attr/icon_share" - app:showAsAction="always" android:orderInCategory="15" - android:title="@string/share_uri_with" > + android:title="@string/share_uri_with" + app:showAsAction="always"> <menu> <item android:id="@+id/action_share_uri" @@ -26,23 +26,11 @@ android:title="@string/show_qr_code" /> </menu> </item> - - <item - android:id="@+id/action_save_as_bookmark" - android:orderInCategory="80" - app:showAsAction="never" - android:title="@string/save_as_bookmark" /> - <item - android:id="@+id/action_delete_bookmark" - android:orderInCategory="80" - app:showAsAction="never" - android:title="@string/delete_bookmark" /> <item android:id="@+id/action_advanced_mode" android:checkable="true" android:checked="false" android:orderInCategory="85" - app:showAsAction="never" - android:title="@string/advanced_mode" /> - + android:title="@string/advanced_mode" + app:showAsAction="never" /> </menu>
\ No newline at end of file |