muc imporvements

This commit is contained in:
kosyak 2024-07-28 09:20:35 -04:00
parent e94aae746d
commit 07bef730aa
11 changed files with 159 additions and 19 deletions

View file

@ -10,6 +10,7 @@ import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import eu.siacs.conversations.Config; import eu.siacs.conversations.Config;
@ -493,6 +494,9 @@ public class MucOptions {
} }
public boolean setSubject(String subject) { public boolean setSubject(String subject) {
if (!Objects.equals(getSubject(), subject)) {
this.conversation.setAttribute("subjectTs", String.valueOf(System.currentTimeMillis()));
}
return this.conversation.setAttribute("subject", subject); return this.conversation.setAttribute("subject", subject);
} }
@ -500,6 +504,27 @@ public class MucOptions {
return this.conversation.getAttribute("subject"); 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() { public String getName() {
return this.conversation.getAttribute("muc_name"); return this.conversation.getAttribute("muc_name");
} }

View file

@ -103,6 +103,7 @@ import eu.siacs.conversations.crypto.axolotl.FingerprintStatus;
import eu.siacs.conversations.databinding.FragmentConversationBinding; import eu.siacs.conversations.databinding.FragmentConversationBinding;
import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Blockable; import eu.siacs.conversations.entities.Blockable;
import eu.siacs.conversations.entities.Bookmark;
import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Conversational; import eu.siacs.conversations.entities.Conversational;
@ -1369,6 +1370,7 @@ public class ConversationFragment extends XmppFragment
public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) {
menuInflater.inflate(R.menu.fragment_conversation, menu); menuInflater.inflate(R.menu.fragment_conversation, menu);
final MenuItem menuMucDetails = menu.findItem(R.id.action_muc_details); 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 menuContactDetails = menu.findItem(R.id.action_contact_details);
final MenuItem menuInviteContact = menu.findItem(R.id.action_invite); final MenuItem menuInviteContact = menu.findItem(R.id.action_invite);
final MenuItem menuMute = menu.findItem(R.id.action_mute); final MenuItem menuMute = menu.findItem(R.id.action_mute);
@ -1390,6 +1392,7 @@ public class ConversationFragment extends XmppFragment
menuCall.setVisible(false); menuCall.setVisible(false);
menuOngoingCall.setVisible(false); menuOngoingCall.setVisible(false);
} else { } else {
menuMucParticipants.setVisible(false);
final XmppConnectionService service = final XmppConnectionService service =
activity == null ? null : activity.xmppConnectionService; activity == null ? null : activity.xmppConnectionService;
final Optional<OngoingRtpSession> ongoingRtpSession = final Optional<OngoingRtpSession> ongoingRtpSession =
@ -2028,6 +2031,11 @@ public class ConversationFragment extends XmppFragment
case R.id.action_muc_details: case R.id.action_muc_details:
ConferenceDetailsActivity.open(activity, conversation); ConferenceDetailsActivity.open(activity, conversation);
break; 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: case R.id.action_invite:
startActivityForResult( startActivityForResult(
ChooseContactActivity.create(activity, conversation), ChooseContactActivity.create(activity, conversation),
@ -2466,7 +2474,7 @@ public class ConversationFragment extends XmppFragment
} }
private void updateChatBG() { private void updateChatBG() {
if (activity != null) { if (activity != null && conversation != null) {
Uri uri = ChatBackgroundHelper.getBgUri(activity, conversation.getUuid()); Uri uri = ChatBackgroundHelper.getBgUri(activity, conversation.getUuid());
if (uri != null) { if (uri != null) {
binding.backgroundImage.setImageURI(uri); binding.backgroundImage.setImageURI(uri);
@ -3603,6 +3611,26 @@ public class ConversationFragment extends XmppFragment
updateSendButton(); updateSendButton();
updateEditablity(); updateEditablity();
conversation.refreshSessions(); 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);
}
} }
} }
} }

View file

@ -778,7 +778,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
menuHideOffline.setChecked(this.mHideOfflineContacts); menuHideOffline.setChecked(this.mHideOfflineContacts);
} }
if (xmppConnectionService.getAccounts().size() != 1) { if (xmppConnectionService != null && xmppConnectionService.getAccounts().size() != 1) {
noteToSelf.setVisible(false); noteToSelf.setVisible(false);
} }
@ -813,6 +813,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
boolean navBarVisible = binding.bottomNavigation.getVisibility() == VISIBLE; boolean navBarVisible = binding.bottomNavigation.getVisibility() == VISIBLE;
MenuItem manageAccount = menu.findItem(R.id.action_account); MenuItem manageAccount = menu.findItem(R.id.action_account);
MenuItem manageAccounts = menu.findItem(R.id.action_accounts); MenuItem manageAccounts = menu.findItem(R.id.action_accounts);
MenuItem noteToSelf = menu.findItem(R.id.action_note_to_self);
if (navBarVisible) { if (navBarVisible) {
manageAccount.setVisible(false); manageAccount.setVisible(false);
manageAccounts.setVisible(false); manageAccounts.setVisible(false);
@ -820,6 +821,10 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
AccountUtils.showHideMenuItems(menu); AccountUtils.showHideMenuItems(menu);
} }
if (xmppConnectionService != null && xmppConnectionService.getAccounts().size() != 1) {
noteToSelf.setVisible(false);
}
return res; return res;
} }
@ -986,6 +991,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
onActivityResult(mPostponedActivityResult.first, RESULT_OK, mPostponedActivityResult.second); onActivityResult(mPostponedActivityResult.first, RESULT_OK, mPostponedActivityResult.second);
this.mPostponedActivityResult = null; this.mPostponedActivityResult = null;
} }
this.mActivatedAccounts.clear(); this.mActivatedAccounts.clear();
this.mActivatedAccounts.addAll(AccountUtils.getEnabledAccounts(xmppConnectionService)); this.mActivatedAccounts.addAll(AccountUtils.getEnabledAccounts(xmppConnectionService));
configureHomeButton(); configureHomeButton();

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:fillColor="#000000"
android:pathData="M256,767.65L192.35,704L416.35,480L192.35,256L256,192.35L480,416.35L704,192.35L767.65,256L543.65,480L767.65,704L704,767.65L480,543.65L256,767.65Z"/>
</vector>

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:pathData="m640,480 l80,80v80L520,640v240l-40,40 -40,-40v-240L240,640v-80l80,-80v-280h-40v-80h400v80h-40v280ZM354,560h252l-46,-46v-314L400,200v314l-46,46ZM480,560Z"
android:fillColor="#000000"/>
</vector>

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:pathData="m640,480 l80,80v80L520,640v240l-40,40 -40,-40v-240L240,640v-80l80,-80v-280h-40v-80h400v80h-40v280ZM354,560h252l-46,-46v-314L400,200v314l-46,46ZM480,560Z"
android:fillColor="#ffffff"/>
</vector>

View file

@ -37,6 +37,47 @@
<RelativeLayout <RelativeLayout
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent"> android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/muc_subject"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:elevation="4dp"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:background="?attr/color_background_tertiary">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:src="?attr/ic_pin"
android:layout_marginEnd="8dp"
/>
<TextView
android:id="@+id/muc_subject_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:ellipsize="end"
android:autoLink="web"
android:textAppearance="@style/TextAppearance.Conversations.Subhead" />
<ImageView
android:id="@+id/muc_subject_hide"
android:layout_width="24dp"
android:layout_height="24dp"
android:src="?attr/ic_close"
android:layout_marginStart="8dp"
/>
</LinearLayout>
<eu.siacs.conversations.ui.DraggableListView <eu.siacs.conversations.ui.DraggableListView
android:id="@+id/messages_view" android:id="@+id/messages_view"
android:layout_width="fill_parent" android:layout_width="fill_parent"
@ -44,11 +85,11 @@
android:layout_above="@+id/snackbar" android:layout_above="@+id/snackbar"
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:divider="@null" android:divider="@null"
android:listSelector="@android:color/transparent" android:listSelector="@android:color/transparent"
android:stackFromBottom="true" android:stackFromBottom="true"
android:transcriptMode="normal" android:transcriptMode="normal"
android:layout_below="@+id/muc_subject"
tools:listitem="@layout/message_sent"/> tools:listitem="@layout/message_sent"/>
<LinearLayout <LinearLayout

View file

@ -83,6 +83,12 @@
android:title="@string/send_location" /> android:title="@string/send_location" />
</menu> </menu>
</item> </item>
<item
android:id="@+id/action_muc_participants"
android:icon="?attr/icon_group"
android:orderInCategory="40"
android:title="@string/action_muc_details"
app:showAsAction="always" />
<item <item
android:id="@+id/action_contact_details" android:id="@+id/action_contact_details"
android:orderInCategory="40" android:orderInCategory="40"

View file

@ -39,6 +39,8 @@
<attr name="ic_send_videocam_offline" format="reference" /> <attr name="ic_send_videocam_offline" format="reference" />
<attr name="ic_send_voice_offline" format="reference" /> <attr name="ic_send_voice_offline" format="reference" />
<attr name="ic_pin" format="reference" />
<attr name="ic_close" format="reference" />
<attr name="ic_attach_camera" format="reference" /> <attr name="ic_attach_camera" format="reference" />
<attr name="ic_attach_videocam" format="reference" /> <attr name="ic_attach_videocam" format="reference" />
<attr name="ic_attach_document" format="reference" /> <attr name="ic_attach_document" format="reference" />

View file

@ -58,6 +58,8 @@
<item name="ic_attach_camera" type="reference">@drawable/ic_attach_camera</item> <item name="ic_attach_camera" type="reference">@drawable/ic_attach_camera</item>
<item name="ic_attach_videocam" type="reference">@drawable/ic_attach_videocam</item> <item name="ic_attach_videocam" type="reference">@drawable/ic_attach_videocam</item>
<item name="ic_attach_document" type="reference">@drawable/ic_attach_document</item> <item name="ic_attach_document" type="reference">@drawable/ic_attach_document</item>
<item name="ic_pin" type="reference">@drawable/ic_pin_black</item>
<item name="ic_close" type="reference">@drawable/ic_close_24dp_black</item>
<item name="ic_attach_location" type="reference">@drawable/ic_attach_location</item> <item name="ic_attach_location" type="reference">@drawable/ic_attach_location</item>
<item name="ic_attach_photo" type="reference">@drawable/ic_attach_photo</item> <item name="ic_attach_photo" type="reference">@drawable/ic_attach_photo</item>
<item name="ic_attach_record" type="reference">@drawable/ic_attach_record</item> <item name="ic_attach_record" type="reference">@drawable/ic_attach_record</item>
@ -235,6 +237,8 @@
<item name="ic_attach_camera" type="reference">@drawable/ic_attach_camera_white</item> <item name="ic_attach_camera" type="reference">@drawable/ic_attach_camera_white</item>
<item name="ic_attach_videocam" type="reference">@drawable/ic_attach_videocam_white</item> <item name="ic_attach_videocam" type="reference">@drawable/ic_attach_videocam_white</item>
<item name="ic_attach_document" type="reference">@drawable/ic_attach_document_white</item> <item name="ic_attach_document" type="reference">@drawable/ic_attach_document_white</item>
<item name="ic_pin" type="reference">@drawable/ic_pin_white</item>
<item name="ic_close" type="reference">@drawable/ic_close_24dp</item>
<item name="ic_attach_location" type="reference">@drawable/ic_attach_location_white</item> <item name="ic_attach_location" type="reference">@drawable/ic_attach_location_white</item>
<item name="ic_attach_photo" type="reference">@drawable/ic_attach_photo_white</item> <item name="ic_attach_photo" type="reference">@drawable/ic_attach_photo_white</item>
<item name="ic_attach_record" type="reference">@drawable/ic_attach_record_white</item> <item name="ic_attach_record" type="reference">@drawable/ic_attach_record_white</item>

View file

@ -212,22 +212,6 @@
android:ringtoneType="ringtone" android:ringtoneType="ringtone"
android:summary="@string/pref_call_ringtone_summary" android:summary="@string/pref_call_ringtone_summary"
android:title="@string/pref_ringtone" /> android:title="@string/pref_ringtone" />
<PreferenceCategory
android:key="unified_push"
android:title="@string/unified_push_distributor">
<ListPreference
android:defaultValue="@string/default_push_account"
android:key="up_push_account"
android:summary="@string/pref_up_push_account_summary"
android:title="@string/pref_up_push_account_title" />
<EditTextPreference
android:defaultValue="@string/default_push_server"
android:key="up_push_server"
android:summary="@string/pref_up_push_server_summary"
android:title="@string/pref_up_push_server_title" />
</PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>
<PreferenceScreen <PreferenceScreen
@ -485,6 +469,23 @@
android:summary="@string/pref_channel_discovery_summary" android:summary="@string/pref_channel_discovery_summary"
android:title="@string/pref_channel_discovery" /> android:title="@string/pref_channel_discovery" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory
android:key="unified_push"
android:title="@string/unified_push_distributor">
<ListPreference
android:defaultValue="@string/default_push_account"
android:key="up_push_account"
android:summary="@string/pref_up_push_account_summary"
android:title="@string/pref_up_push_account_title" />
<EditTextPreference
android:defaultValue="@string/default_push_server"
android:key="up_push_server"
android:summary="@string/pref_up_push_server_summary"
android:title="@string/pref_up_push_server_title" />
</PreferenceCategory>
<intent <intent
android:action="android.intent.action.VIEW" android:action="android.intent.action.VIEW"
android:targetClass="eu.siacs.conversations.ui.SettingsActivity" android:targetClass="eu.siacs.conversations.ui.SettingsActivity"