diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-12-30 22:28:22 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-12-30 22:28:22 +0100 |
commit | 11898675220b94ae7531d61d45afced7f129aa3b (patch) | |
tree | 4043464499a715bf7b66c46ac87d1dbc94fc3808 | |
parent | 4e78a72af907ac32eccd87ebdbf6ec44a4336d36 (diff) |
add ability to configure autojoin flag in groupchat details
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java | 21 | ||||
-rw-r--r-- | src/main/res/layout/activity_muc_details.xml | 67 | ||||
-rw-r--r-- | 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 @@ <RelativeLayout android:id="@+id/muc_info_more" - android:layout_width="fill_parent" - android:layout_height="wrap_content"> + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> - <TextView + <CheckBox + android:id="@+id/autojoin_checkbox" + style="@style/Widget.Conversations.CheckBox" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_alignParentStart="true" - android:layout_alignParentLeft="true" - android:layout_centerVertical="true" - android:layout_toStartOf="@+id/muc_info_mam" - android:layout_toLeftOf="@+id/muc_info_mam" - android:ellipsize="end" - android:singleLine="true" - android:text="@string/server_info_mam" + android:layout_marginStart="-6dp" + android:layout_marginLeft="-6dp" + android:layout_marginTop="4dp" + android:text="@string/autojoin_groupchat" android:textAppearance="@style/TextAppearance.Conversations.Body1" /> - <TextView - android:id="@+id/muc_info_mam" - style="?android:attr/buttonStyleSmall" - android:layout_width="wrap_content" + <RelativeLayout + android:id="@+id/mam_box" + android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_alignParentEnd="true" - android:layout_alignParentRight="true" - android:layout_centerVertical="true" - android:layout_gravity="center_horizontal" - android:background="?attr/selectableItemBackgroundBorderless" - android:padding="@dimen/image_button_padding" - android:paddingStart="4dp" - android:paddingLeft="4dp" - android:textAppearance="@style/TextAppearance.Conversations.Body1" /> + android:layout_below="@+id/autojoin_checkbox"> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_alignParentStart="true" + android:layout_alignParentLeft="true" + android:layout_centerVertical="true" + android:layout_toStartOf="@+id/muc_info_mam" + android:layout_toLeftOf="@+id/muc_info_mam" + android:ellipsize="end" + android:singleLine="true" + android:text="@string/server_info_mam" + android:textAppearance="@style/TextAppearance.Conversations.Body1" /> + + <TextView + android:id="@+id/muc_info_mam" + style="?android:attr/buttonStyleSmall" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentEnd="true" + android:layout_alignParentRight="true" + android:layout_centerVertical="true" + android:layout_gravity="center_horizontal" + android:background="?attr/selectableItemBackgroundBorderless" + android:padding="@dimen/image_button_padding" + android:paddingStart="4dp" + android:paddingLeft="4dp" + android:textAppearance="@style/TextAppearance.Conversations.Body1" /> + </RelativeLayout> </RelativeLayout> </LinearLayout> 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 @@ <string name="enter_your_name">Enter your name</string> <string name="enter_your_name_instructions">Please enter your nickname which will be visible to your contacts.</string> <string name="no_name_set_instructions">No nickname set.</string> + <string name="autojoin_groupchat">Automatically join this group chat</string> </resources> |