From 11898675220b94ae7531d61d45afced7f129aa3b Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sun, 30 Dec 2018 22:28:22 +0100 Subject: add ability to configure autojoin flag in groupchat details --- .../messenger/ui/ConferenceDetailsActivity.java | 21 ++++++- src/main/res/layout/activity_muc_details.xml | 67 ++++++++++++++-------- src/main/res/values/strings.xml | 1 + 3 files changed, 64 insertions(+), 25 deletions(-) diff --git a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java index 583f3d3ad..7c9a5830b 100644 --- a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java @@ -25,6 +25,7 @@ import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.WindowManager; +import android.widget.CompoundButton; import android.widget.ImageView; import android.widget.Toast; @@ -332,6 +333,14 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers this.binding.mucEditTitle.addTextChangedListener(this); this.binding.mucEditSubject.addTextChangedListener(this); this.binding.mucEditSubject.addTextChangedListener(new StylingHelper.MessageEditorStyler(this.binding.mucEditSubject)); + this.binding.autojoinCheckbox.setOnCheckedChangeListener((buttonView, isChecked) -> { + final Bookmark bookmark = mConversation.getBookmark(); + if (bookmark != null) { + bookmark.setAutojoin(this.binding.autojoinCheckbox.isChecked()); + xmppConnectionService.pushBookmarks(bookmark.getAccount()); + updateView(); + } + }); mMediaAdapter = new MediaAdapter(this, R.dimen.media_size); this.binding.media.setAdapter(mMediaAdapter); GridManager.setupLayoutManager(this, this.binding.media, R.dimen.media_size); @@ -551,6 +560,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers return; } final MucOptions mucOptions = mConversation.getMucOptions(); + final Bookmark bookmark = mConversation.getBookmark(); final User self = mucOptions.getSelf(); String account; if (Config.DOMAIN_LOCK != null) { @@ -559,7 +569,6 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers account = mConversation.getAccount().getJid().asBareJid().toString(); } - this.binding.editMucNameButton.setVisibility((self.getAffiliation().ranks(MucOptions.Affiliation.OWNER) || mucOptions.canChangeSubject()) ? View.VISIBLE : View.GONE); this.binding.detailsAccount.setText(getString(R.string.using_account, account)); this.binding.jid.setText(mConversation.getJid().asBareJid().toEscapedString()); @@ -614,6 +623,16 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers } else { this.binding.mucInfoMam.setText(R.string.server_info_unavailable); } + if (bookmark != null) { + this.binding.autojoinCheckbox.setVisibility(View.VISIBLE); + if (bookmark.autojoin()) { + this.binding.autojoinCheckbox.setChecked(true); + } else { + this.binding.autojoinCheckbox.setChecked(false); + } + } else { + this.binding.autojoinCheckbox.setVisibility(View.GONE); + } if (self.getAffiliation().ranks(MucOptions.Affiliation.OWNER)) { if (mAdvancedMode) { this.binding.destroy.getBackground().setColorFilter(getWarningButtonColor(), PorterDuff.Mode.MULTIPLY); diff --git a/src/main/res/layout/activity_muc_details.xml b/src/main/res/layout/activity_muc_details.xml index 04198908a..d93d737e6 100644 --- a/src/main/res/layout/activity_muc_details.xml +++ b/src/main/res/layout/activity_muc_details.xml @@ -222,36 +222,55 @@ + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> - - + android:layout_below="@+id/autojoin_checkbox"> + + + + + diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 96b095277..015a2a6c6 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -854,4 +854,5 @@ Enter your name Please enter your nickname which will be visible to your contacts. No nickname set. + Automatically join this group chat -- cgit v1.2.3