diff --git a/src/main/java/eu/siacs/conversations/entities/MucOptions.java b/src/main/java/eu/siacs/conversations/entities/MucOptions.java index c408d147f..5dccc4a4b 100644 --- a/src/main/java/eu/siacs/conversations/entities/MucOptions.java +++ b/src/main/java/eu/siacs/conversations/entities/MucOptions.java @@ -10,6 +10,7 @@ import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Locale; +import java.util.Objects; import java.util.Set; import eu.siacs.conversations.Config; @@ -493,6 +494,9 @@ public class MucOptions { } public boolean setSubject(String subject) { + if (!Objects.equals(getSubject(), subject)) { + this.conversation.setAttribute("subjectTs", String.valueOf(System.currentTimeMillis())); + } return this.conversation.setAttribute("subject", subject); } @@ -500,6 +504,27 @@ public class MucOptions { return this.conversation.getAttribute("subject"); } + public void hideSubject() { + String subjectTs = this.conversation.getAttribute("subjectTs"); + + if (subjectTs == null) { + this.conversation.setAttribute("subjectTs", String.valueOf(System.currentTimeMillis() - 1)); + } + + this.conversation.setAttribute("subjectHideTs", String.valueOf(System.currentTimeMillis())); + } + + public boolean subjectHidden() { + String subjectTs = this.conversation.getAttribute("subjectTs"); + String hideTs = this.conversation.getAttribute("subjectHideTs"); + + if (subjectTs == null || hideTs == null) { + return false; + } else { + return Long.parseLong(hideTs) >= Long.parseLong(subjectTs); + } + } + public String getName() { return this.conversation.getAttribute("muc_name"); } diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 4f2425e0f..285e15832 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -103,6 +103,7 @@ import eu.siacs.conversations.crypto.axolotl.FingerprintStatus; import eu.siacs.conversations.databinding.FragmentConversationBinding; import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Blockable; +import eu.siacs.conversations.entities.Bookmark; import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Conversational; @@ -1369,6 +1370,7 @@ public class ConversationFragment extends XmppFragment public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) { menuInflater.inflate(R.menu.fragment_conversation, menu); final MenuItem menuMucDetails = menu.findItem(R.id.action_muc_details); + final MenuItem menuMucParticipants = menu.findItem(R.id.action_muc_participants); final MenuItem menuContactDetails = menu.findItem(R.id.action_contact_details); final MenuItem menuInviteContact = menu.findItem(R.id.action_invite); final MenuItem menuMute = menu.findItem(R.id.action_mute); @@ -1390,6 +1392,7 @@ public class ConversationFragment extends XmppFragment menuCall.setVisible(false); menuOngoingCall.setVisible(false); } else { + menuMucParticipants.setVisible(false); final XmppConnectionService service = activity == null ? null : activity.xmppConnectionService; final Optional ongoingRtpSession = @@ -2028,6 +2031,11 @@ public class ConversationFragment extends XmppFragment case R.id.action_muc_details: ConferenceDetailsActivity.open(activity, conversation); break; + case R.id.action_muc_participants: + Intent intent = new Intent(activity, MucUsersActivity.class); + intent.putExtra("uuid", conversation.getUuid()); + activity.startActivity(intent); + break; case R.id.action_invite: startActivityForResult( ChooseContactActivity.create(activity, conversation), @@ -2466,7 +2474,7 @@ public class ConversationFragment extends XmppFragment } private void updateChatBG() { - if (activity != null) { + if (activity != null && conversation != null) { Uri uri = ChatBackgroundHelper.getBgUri(activity, conversation.getUuid()); if (uri != null) { binding.backgroundImage.setImageURI(uri); @@ -3603,6 +3611,26 @@ public class ConversationFragment extends XmppFragment updateSendButton(); updateEditablity(); conversation.refreshSessions(); + + + if (conversation != null && conversation.getMode() == Conversational.MODE_MULTI) { + String subject = conversation.getMucOptions().getSubject(); + Boolean hidden = conversation.getMucOptions().subjectHidden(); + + if (Bookmark.printableValue(subject) && !hidden) { + binding.mucSubjectText.setText(subject); + binding.mucSubject.setOnClickListener(v -> ConferenceDetailsActivity.open(getActivity(), conversation)); + binding.mucSubjectHide.setOnClickListener(v -> { + conversation.getMucOptions().hideSubject(); + binding.mucSubject.setVisibility(View.GONE); + }); + binding.mucSubject.setVisibility(View.VISIBLE); + } else { + binding.mucSubject.setVisibility(View.GONE); + } + } else { + binding.mucSubject.setVisibility(View.GONE); + } } } } diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java index 4a1439e84..fe787e752 100644 --- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java @@ -778,7 +778,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne menuHideOffline.setChecked(this.mHideOfflineContacts); } - if (xmppConnectionService.getAccounts().size() != 1) { + if (xmppConnectionService != null && xmppConnectionService.getAccounts().size() != 1) { noteToSelf.setVisible(false); } @@ -813,6 +813,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne boolean navBarVisible = binding.bottomNavigation.getVisibility() == VISIBLE; MenuItem manageAccount = menu.findItem(R.id.action_account); MenuItem manageAccounts = menu.findItem(R.id.action_accounts); + MenuItem noteToSelf = menu.findItem(R.id.action_note_to_self); if (navBarVisible) { manageAccount.setVisible(false); manageAccounts.setVisible(false); @@ -820,6 +821,10 @@ public class StartConversationActivity extends XmppActivity implements XmppConne AccountUtils.showHideMenuItems(menu); } + if (xmppConnectionService != null && xmppConnectionService.getAccounts().size() != 1) { + noteToSelf.setVisible(false); + } + return res; } @@ -986,6 +991,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne onActivityResult(mPostponedActivityResult.first, RESULT_OK, mPostponedActivityResult.second); this.mPostponedActivityResult = null; } + this.mActivatedAccounts.clear(); this.mActivatedAccounts.addAll(AccountUtils.getEnabledAccounts(xmppConnectionService)); configureHomeButton(); diff --git a/src/main/res/drawable/ic_close_24dp_black.xml b/src/main/res/drawable/ic_close_24dp_black.xml new file mode 100644 index 000000000..084ef0dfa --- /dev/null +++ b/src/main/res/drawable/ic_close_24dp_black.xml @@ -0,0 +1,9 @@ + + + diff --git a/src/main/res/drawable/ic_pin_black.xml b/src/main/res/drawable/ic_pin_black.xml new file mode 100644 index 000000000..bce5ac34d --- /dev/null +++ b/src/main/res/drawable/ic_pin_black.xml @@ -0,0 +1,9 @@ + + + diff --git a/src/main/res/drawable/ic_pin_white.xml b/src/main/res/drawable/ic_pin_white.xml new file mode 100644 index 000000000..0d19fe609 --- /dev/null +++ b/src/main/res/drawable/ic_pin_white.xml @@ -0,0 +1,9 @@ + + + diff --git a/src/main/res/layout/fragment_conversation.xml b/src/main/res/layout/fragment_conversation.xml index 0efee1f09..81f3247a7 100644 --- a/src/main/res/layout/fragment_conversation.xml +++ b/src/main/res/layout/fragment_conversation.xml @@ -37,6 +37,47 @@ + + + + + + + + + + + + + + diff --git a/src/main/res/values/themes.xml b/src/main/res/values/themes.xml index 84bb05ce2..59f613037 100644 --- a/src/main/res/values/themes.xml +++ b/src/main/res/values/themes.xml @@ -58,6 +58,8 @@ @drawable/ic_attach_camera @drawable/ic_attach_videocam @drawable/ic_attach_document + @drawable/ic_pin_black + @drawable/ic_close_24dp_black @drawable/ic_attach_location @drawable/ic_attach_photo @drawable/ic_attach_record @@ -235,6 +237,8 @@ @drawable/ic_attach_camera_white @drawable/ic_attach_videocam_white @drawable/ic_attach_document_white + @drawable/ic_pin_white + @drawable/ic_close_24dp @drawable/ic_attach_location_white @drawable/ic_attach_photo_white @drawable/ic_attach_record_white diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml index d1b1790ec..c4eaf0fd6 100644 --- a/src/main/res/xml/preferences.xml +++ b/src/main/res/xml/preferences.xml @@ -212,22 +212,6 @@ android:ringtoneType="ringtone" android:summary="@string/pref_call_ringtone_summary" android:title="@string/pref_ringtone" /> - - - - - - + + + + + + +