Pin room details to top in chat rooms + add participants menu to chat rooms + add note to self menu if only one account available
This commit is contained in:
parent
8e76d8b052
commit
fcd164648a
7 changed files with 116 additions and 3 deletions
|
@ -12,6 +12,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 io.ipfs.cid.Cid;
|
||||
|
@ -585,6 +586,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);
|
||||
}
|
||||
|
||||
|
@ -592,6 +596,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");
|
||||
}
|
||||
|
|
|
@ -133,6 +133,7 @@ import net.java.otr4j.session.SessionStatus;
|
|||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import eu.siacs.conversations.entities.Bookmark;
|
||||
import eu.siacs.conversations.medialib.activities.EditActivity;
|
||||
import eu.siacs.conversations.ui.util.QuoteHelper;
|
||||
import eu.siacs.conversations.utils.ChatBackgroundHelper;
|
||||
|
@ -1633,6 +1634,7 @@ public class ConversationFragment extends XmppFragment
|
|||
|
||||
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);
|
||||
|
@ -1654,6 +1656,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> ongoingRtpSession =
|
||||
|
@ -2467,6 +2470,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_user = new Intent(activity, MucUsersActivity.class);
|
||||
intent_user.putExtra("uuid", conversation.getUuid());
|
||||
activity.startActivity(intent_user);
|
||||
break;
|
||||
case R.id.action_invite:
|
||||
startActivityForResult(
|
||||
ChooseContactActivity.create(activity, conversation),
|
||||
|
@ -2998,7 +3006,7 @@ public class ConversationFragment extends XmppFragment
|
|||
}
|
||||
|
||||
private void updateChatBG() {
|
||||
if (activity != null) {
|
||||
if (activity != null && conversation != null) {
|
||||
if (activity.unicoloredBG()) {
|
||||
binding.conversationsFragment.setBackgroundResource(0);
|
||||
} else {
|
||||
|
@ -4375,6 +4383,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -963,12 +963,16 @@ public class StartConversationActivity extends XmppActivity
|
|||
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);
|
||||
} else {
|
||||
AccountUtils.showHideMenuItems(menu);
|
||||
}
|
||||
if (xmppConnectionService != null && xmppConnectionService.getAccounts().size() != 1) {
|
||||
noteToSelf.setVisible(false);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
5
src/main/res/drawable/outline_push_pin_24.xml
Normal file
5
src/main/res/drawable/outline_push_pin_24.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="?colorControlNormal" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||
|
||||
<path android:fillColor="@android:color/white" android:pathData="M14,4v5c0,1.12 0.37,2.16 1,3H9c0.65,-0.86 1,-1.9 1,-3V4H14M17,2H7C6.45,2 6,2.45 6,3c0,0.55 0.45,1 1,1c0,0 0,0 0,0l1,0v5c0,1.66 -1.34,3 -3,3v2h5.97v7l1,1l1,-1v-7H19v-2c0,0 0,0 0,0c-1.66,0 -3,-1.34 -3,-3V4l1,0c0,0 0,0 0,0c0.55,0 1,-0.45 1,-1C18,2.45 17.55,2 17,2L17,2z"/>
|
||||
|
||||
</vector>
|
|
@ -32,18 +32,59 @@
|
|||
android:layout_width="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/colorOnTertiary">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:src="@drawable/outline_push_pin_24"
|
||||
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:singleLine="true"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:autoLink="web"
|
||||
android:textAppearance="?textAppearanceCaption" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/muc_subject_hide"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:src="@drawable/rounded_close_24"
|
||||
android:layout_marginStart="8dp"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ListView
|
||||
android:id="@+id/messages_view"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@+id/snackbar"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:divider="@null"
|
||||
android:dividerHeight="0dp"
|
||||
android:listSelector="@android:color/transparent"
|
||||
android:stackFromBottom="true"
|
||||
android:transcriptMode="normal"
|
||||
android:layout_below="@+id/muc_subject"
|
||||
tools:listitem="@layout/item_message_sent" />
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -90,6 +90,12 @@
|
|||
android:title="@string/schedule_message" />
|
||||
</menu>
|
||||
</item>
|
||||
<item
|
||||
android:id="@+id/action_muc_participants"
|
||||
android:icon="@drawable/ic_group_24dp"
|
||||
android:orderInCategory="40"
|
||||
android:title="@string/action_muc_details"
|
||||
app:showAsAction="ifRoom" />
|
||||
<item
|
||||
android:id="@+id/action_contact_details"
|
||||
android:orderInCategory="40"
|
||||
|
|
|
@ -13,7 +13,11 @@
|
|||
android:icon="@drawable/ic_qr_code_scanner_24dp"
|
||||
android:title="@string/scan_qr_code"
|
||||
app:showAsAction="always" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_note_to_self"
|
||||
android:orderInCategory="80"
|
||||
android:title="@string/note_to_self"
|
||||
app:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/action_hide_offline"
|
||||
android:checkable="true"
|
||||
|
|
Loading…
Reference in a new issue