closed_groups
SessionHero01 5 months ago
parent 905acab3f4
commit 7520571a7d
No known key found for this signature in database

@ -1,13 +1,9 @@
package org.thoughtcrime.securesms.groups.compose
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
@ -15,34 +11,16 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.selection.toggleable
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.Checkbox
import androidx.compose.material3.CheckboxDefaults
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment.Companion.CenterVertically
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalInspectionMode
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import network.loki.messenger.R
import network.loki.messenger.libsession_util.util.Contact
import org.session.libsession.utilities.Address
import org.session.libsession.utilities.recipients.Recipient
import org.session.libsignal.utilities.AccountId
import org.thoughtcrime.securesms.groups.ContactItem
import org.thoughtcrime.securesms.ui.Avatar
@ -123,25 +101,8 @@ fun RowScope.MemberName(
@Composable
fun ContactPhoto(sessionId: AccountId) {
return if (LocalInspectionMode.current) {
Image(
painterResource(id = R.drawable.ic_profile_default),
colorFilter = ColorFilter.tint(LocalColors.current.textSecondary),
contentScale = ContentScale.Inside,
contentDescription = null,
modifier = Modifier
.size(48.dp)
.clip(CircleShape)
.border(1.dp, LocalColors.current.borders, CircleShape)
)
} else {
val context = LocalContext.current
// Ideally we migrate to something that doesn't require recipient, or get contact photo another way
val recipient = remember(sessionId) {
Recipient.from(context, Address.fromSerialized(sessionId.hexString), false)
}
Avatar(recipient, modifier = Modifier.size(48.dp))
}
Avatar(Address.fromSerialized(sessionId.hexString),
modifier = Modifier.size(LocalDimensions.current.iconLarge))
}

@ -8,6 +8,7 @@ import androidx.compose.foundation.Canvas
import androidx.compose.foundation.Image
import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.Column
@ -28,6 +29,7 @@ import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.material3.ButtonColors
@ -43,6 +45,7 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.drawWithContent
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.BlendMode
@ -55,7 +58,9 @@ import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalInspectionMode
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.contentDescription
@ -432,12 +437,25 @@ fun Avatar(
userAddress: Address,
modifier: Modifier = Modifier
) {
AndroidView(
factory = {
ProfilePictureView(it).apply { update(userAddress) }
},
modifier = modifier
)
if (LocalInspectionMode.current) {
Image(
painterResource(id = R.drawable.ic_profile_default),
colorFilter = ColorFilter.tint(LocalColors.current.textSecondary),
contentScale = ContentScale.Inside,
contentDescription = null,
modifier = Modifier
.size(LocalDimensions.current.iconLarge)
.clip(CircleShape)
.border(1.dp, LocalColors.current.borders, CircleShape)
)
} else {
AndroidView(
factory = {
ProfilePictureView(it).apply { update(userAddress) }
},
modifier = modifier
)
}
}
@Composable

@ -17,7 +17,6 @@ import androidx.compose.ui.Alignment.Companion.CenterVertically
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import org.thoughtcrime.securesms.ui.theme.LocalColors
import org.thoughtcrime.securesms.ui.theme.LocalDimensions
import org.thoughtcrime.securesms.ui.theme.LocalType
@ -53,7 +52,7 @@ fun <T> BottomOptionsDialog(
containerColor = LocalColors.current.backgroundSecondary,
) {
for (option in options) {
MemberModalBottomSheetOptionItem(
BottomOptionItem(
text = optionTitle(option),
leadingIcon = optionIconRes(option),
onClick = {
@ -66,7 +65,7 @@ fun <T> BottomOptionsDialog(
}
@Composable
private fun MemberModalBottomSheetOptionItem(
private fun BottomOptionItem(
leadingIcon: Int,
text: String,
onClick: () -> Unit
@ -81,7 +80,7 @@ private fun MemberModalBottomSheetOptionItem(
) {
Icon(
painter = painterResource(leadingIcon),
modifier = Modifier.size(24.dp),
modifier = Modifier.size(LocalDimensions.current.iconMedium),
tint = LocalColors.current.text,
contentDescription = null
)

@ -49,6 +49,4 @@ val dangerLight = Color(0xFFE12D19)
val disabledDark = Color(0xFFA1A2A1)
val disabledLight = Color(0xFF6D6D6D)
val warningUniversal = Color(0xFFFCB159)
val blackAlpha40 = Color.Black.copy(alpha = 0.4f)

@ -20,5 +20,8 @@ data class Dimensions(
val minLargeItemButtonHeight: Dp = 60.dp,
val indicatorHeight: Dp = 4.dp,
val borderStroke: Dp = 1.dp
val borderStroke: Dp = 1.dp,
val iconMedium: Dp = 24.dp,
val iconLarge: Dp = 48.dp,
)

@ -1,18 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="44dp"
android:height="35dp"
android:viewportWidth="44"
android:viewportHeight="35">
<path
android:pathData="M34.951,23.398L26.63,17.311C26.575,17.267 26.507,17.243 26.438,17.243C26.368,17.243 26.299,17.267 26.245,17.311L18.784,23.488C18.727,23.531 18.657,23.554 18.585,23.554C18.513,23.554 18.444,23.531 18.386,23.488L14.637,20.432C14.583,20.391 14.517,20.369 14.45,20.369C14.383,20.369 14.318,20.391 14.264,20.432L4.107,27.648C4.068,27.679 4.036,27.718 4.014,27.762C3.991,27.807 3.979,27.855 3.978,27.905V30.242C3.982,30.435 4.06,30.619 4.196,30.756C4.333,30.893 4.517,30.971 4.71,30.974H34.348C34.542,30.974 34.728,30.897 34.865,30.76C35.002,30.622 35.08,30.436 35.08,30.242V23.642C35.081,23.594 35.07,23.546 35.047,23.503C35.025,23.46 34.992,23.424 34.951,23.398Z"
android:fillColor="?colorOnSurface"/>
<path
android:pathData="M11.131,18.248C12.726,18.248 14.02,16.955 14.02,15.359C14.02,13.763 12.726,12.47 11.131,12.47C9.535,12.47 8.242,13.763 8.242,15.359C8.242,16.955 9.535,18.248 11.131,18.248Z"
android:fillColor="?colorOnSurface"/>
<path
android:pathData="M40.396,4.123L8.229,0.374C7.807,0.322 7.38,0.354 6.971,0.47C6.563,0.585 6.181,0.78 5.849,1.044C5.517,1.308 5.24,1.636 5.036,2.008C4.832,2.38 4.703,2.789 4.659,3.212L4.505,4.598H7.073L7.201,3.507C7.212,3.424 7.239,3.343 7.281,3.27C7.323,3.198 7.379,3.134 7.445,3.083C7.555,2.995 7.69,2.946 7.831,2.942H7.895L22.187,4.598H35.722C36.512,4.603 37.29,4.789 37.996,5.143C38.702,5.498 39.316,6.01 39.792,6.64H40.1C40.269,6.659 40.423,6.745 40.528,6.877C40.634,7.009 40.683,7.178 40.666,7.346L40.576,8.078C40.755,8.595 40.85,9.137 40.858,9.683V27.995L43.221,7.68C43.315,6.834 43.071,5.986 42.541,5.319C42.012,4.653 41.241,4.223 40.396,4.123Z"
android:fillColor="?colorOnSurface"/>
<path
android:pathData="M35.722,34.801H3.336C2.485,34.801 1.668,34.463 1.066,33.861C0.464,33.258 0.126,32.442 0.126,31.59V9.761C0.126,8.909 0.464,8.093 1.066,7.49C1.668,6.888 2.485,6.55 3.336,6.55H35.722C36.573,6.55 37.39,6.888 37.992,7.49C38.594,8.093 38.932,8.909 38.932,9.761V31.59C38.932,32.442 38.594,33.258 37.992,33.861C37.39,34.463 36.573,34.801 35.722,34.801ZM3.336,9.093C3.166,9.093 3.003,9.16 2.882,9.281C2.762,9.401 2.694,9.565 2.694,9.735V31.565C2.694,31.735 2.762,31.898 2.882,32.019C3.003,32.139 3.166,32.207 3.336,32.207H35.722C35.892,32.207 36.055,32.139 36.176,32.019C36.296,31.898 36.364,31.735 36.364,31.565V9.735C36.364,9.565 36.296,9.401 36.176,9.281C36.055,9.16 35.892,9.093 35.722,9.093H3.336Z"
android:fillColor="?colorOnSurface"/>
</vector>

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="22dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M17,7l-1.41,1.41L18.17,11H8v2h10.17l-2.58,2.58L17,17l5,-5zM4,5h8V3H4c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h8v-2H4V5z"/>
</vector>

@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="50"
android:viewportHeight="50">
<path
android:pathData="M10.417,9.317C9.864,9.317 9.335,9.536 8.944,9.927C8.553,10.318 8.334,10.847 8.334,11.4V40.567C8.334,41.119 8.553,41.649 8.944,42.04C9.335,42.43 9.864,42.65 10.417,42.65H18.75C19.901,42.65 20.834,43.583 20.834,44.733C20.834,45.884 19.901,46.817 18.75,46.817H10.417C8.759,46.817 7.17,46.158 5.998,44.986C4.825,43.814 4.167,42.224 4.167,40.567V11.4C4.167,9.742 4.825,8.153 5.998,6.98C7.17,5.808 8.759,5.15 10.417,5.15H18.75C19.901,5.15 20.834,6.083 20.834,7.233C20.834,8.384 19.901,9.317 18.75,9.317H10.417Z"
android:fillColor="#000000"
android:fillType="evenOdd"/>
<path
android:pathData="M31.86,14.094C32.674,13.28 33.993,13.28 34.806,14.094L45.223,24.51C46.037,25.324 46.037,26.643 45.223,27.456L34.806,37.873C33.993,38.687 32.674,38.687 31.86,37.873C31.047,37.06 31.047,35.741 31.86,34.927L40.804,25.983L31.86,17.04C31.047,16.226 31.047,14.907 31.86,14.094Z"
android:fillColor="#000000"
android:fillType="evenOdd"/>
<path
android:pathData="M16.667,25.983C16.667,24.833 17.6,23.9 18.75,23.9H43.75C44.901,23.9 45.834,24.833 45.834,25.983C45.834,27.134 44.901,28.067 43.75,28.067H18.75C17.6,28.067 16.667,27.134 16.667,25.983Z"
android:fillColor="#000000"
android:fillType="evenOdd"/>
</vector>

@ -13,66 +13,66 @@
android:id="@+id/detailsTextView"
style="@style/BottomSheetActionItem"
android:contentDescription="@string/AccessibilityId_contactUserDetails"
android:drawableStart="@drawable/ic_info_outline_white_24dp"
android:drawableTint="?attr/colorControlNormal"
android:text="@string/contactUserDetails" />
android:text="@string/contactUserDetails"
app:drawableStartCompat="@drawable/ic_info_outline_white_24dp"
app:drawableTint="?attr/colorControlNormal" />
<TextView
android:id="@+id/copyConversationId"
style="@style/BottomSheetActionItem"
android:drawableStart="@drawable/ic_copy"
android:drawableTint="?attr/colorControlNormal"
android:visibility="visible"
android:text="@string/accountIDCopy" />
android:text="@string/accountIDCopy"
app:drawableStartCompat="@drawable/ic_copy"
app:drawableTint="?attr/colorControlNormal" />
<TextView
android:id="@+id/copyCommunityUrl"
style="@style/BottomSheetActionItem"
android:drawableStart="@drawable/ic_copy"
android:drawableTint="?attr/colorControlNormal"
android:visibility="gone"
android:text="@string/communityUrlCopy" />
android:text="@string/communityUrlCopy"
app:drawableStartCompat="@drawable/ic_copy"
app:drawableTint="?attr/colorControlNormal" />
<TextView
android:id="@+id/pinTextView"
style="@style/BottomSheetActionItem"
android:contentDescription="@string/AccessibilityId_pin"
android:drawableStart="?attr/menu_pin_icon"
android:text="@string/pin"
android:visibility="gone"
app:drawableStartCompat="?attr/menu_pin_icon"
tools:visibility="visible" />
<TextView
android:id="@+id/unpinTextView"
style="@style/BottomSheetActionItem"
android:drawableStart="?attr/menu_unpin_icon"
android:text="@string/pinUnpin"
android:visibility="gone"
app:drawableStartCompat="?attr/menu_unpin_icon"
tools:visibility="visible" />
<TextView
android:id="@+id/blockTextView"
style="@style/BottomSheetActionItem"
android:contentDescription="@string/AccessibilityId_block"
android:drawableStart="?attr/menu_block_icon"
android:text="@string/block"
android:visibility="gone"
app:drawableStartCompat="?attr/menu_block_icon"
tools:visibility="visible" />
<TextView
android:id="@+id/unblockTextView"
style="@style/BottomSheetActionItem"
android:drawableStart="?attr/menu_accept_icon"
android:text="@string/blockUnblock"
android:visibility="gone"
app:drawableStartCompat="?attr/menu_accept_icon"
tools:visibility="visible" />
<TextView
android:id="@+id/muteNotificationsTextView"
style="@style/BottomSheetActionItem"
android:contentDescription="@string/AccessibilityId_notificationsMute"
android:drawableStart="@drawable/ic_outline_notifications_off_24"
android:text="@string/notificationsMute"
app:drawableStartCompat="@drawable/ic_outline_notifications_off_24"
tools:visibility="visible"
android:visibility="gone"
/>
@ -80,8 +80,8 @@
<TextView
android:id="@+id/unMuteNotificationsTextView"
style="@style/BottomSheetActionItem"
android:drawableStart="@drawable/ic_outline_notifications_active_24"
android:text="@string/notificationsMuteUnmute"
app:drawableStartCompat="@drawable/ic_outline_notifications_active_24"
tools:visibility="visible"
android:visibility="gone"
/>
@ -89,8 +89,8 @@
<TextView
android:id="@+id/notificationsTextView"
style="@style/BottomSheetActionItem"
android:drawableStart="@drawable/ic_outline_notification_important_24"
android:text="@string/sessionNotifications"
app:drawableStartCompat="@drawable/ic_outline_notification_important_24"
tools:visibility="visible"
android:visibility="gone"
/>
@ -98,23 +98,22 @@
<TextView
android:id="@+id/markAllAsReadTextView"
style="@style/BottomSheetActionItem"
android:drawableStart="?attr/menu_mark_all_as_read"
android:text="@string/messageMarkRead"
android:visibility="gone"
/>
app:drawableStartCompat="?attr/menu_mark_all_as_read" />
<TextView
android:id="@+id/deleteTextView"
style="@style/BottomSheetActionItem"
android:contentDescription="@string/AccessibilityId_delete"
android:drawableStart="?attr/menu_trash_icon"
android:text="@string/delete" />
android:text="@string/delete"
app:drawableStartCompat="?attr/menu_trash_icon" />
<TextView
android:id="@+id/leaveTextView"
style="@style/BottomSheetActionItem"
android:paddingStart="20dp"
android:drawableStart="@drawable/ic_baseline_logout_24"
android:text="@string/leave" />
android:text="@string/leave"
app:drawableStartCompat="@drawable/ic_log_out"
app:drawableTint="?android:attr/textColorPrimary" />
</LinearLayout>

@ -1,47 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<org.thoughtcrime.securesms.components.ProfilePictureView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/doubleModeImageViewContainer"
android:layout_centerInParent="true"
android:layout_width="@dimen/extra_large_profile_picture_size"
android:layout_height="@dimen/extra_large_profile_picture_size">
<ImageView
android:layout_margin="@dimen/small_spacing"
android:id="@+id/doubleModeImageView1"
android:layout_width="@dimen/large_profile_picture_size"
android:layout_height="@dimen/large_profile_picture_size"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="@drawable/profile_picture_view_large_background" />
<ImageView
android:layout_margin="@dimen/small_spacing"
android:id="@+id/doubleModeImageView2"
android:layout_width="@dimen/large_profile_picture_size"
android:layout_height="@dimen/large_profile_picture_size"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:background="@drawable/profile_picture_view_large_background" />
</RelativeLayout>
<ImageView
android:layout_centerInParent="true"
android:id="@+id/singleModeImageView"
android:layout_width="@dimen/large_profile_picture_size"
android:layout_height="@dimen/large_profile_picture_size"
android:background="@drawable/profile_picture_view_large_background" />
<ImageView
android:layout_centerInParent="true"
android:id="@+id/largeSingleModeImageView"
android:layout_width="@dimen/extra_large_profile_picture_size"
android:layout_height="@dimen/extra_large_profile_picture_size"
android:background="@drawable/profile_picture_view_large_background" />
</org.thoughtcrime.securesms.components.ProfilePictureView>

@ -12,8 +12,6 @@ android {
defaultConfig {
minSdkVersion androidMinimumSdkVersion
// Build constant for which version should minimally support new groups
buildConfigField("String", "MINIMUM_GROUP_VERSION", '"1.19.0"')
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

@ -73,11 +73,11 @@ public class IncomingMediaMessage {
if (group.isPresent()) {
SignalServiceGroup groupObject = group.get();
if (groupObject.isNewClosedGroup()) {
// new closed group 03..etc..
if (groupObject.isGroupV2()) {
// new groupv2 03..etc..
this.groupId = Address.fromSerialized(Hex.toStringCondensed(groupObject.getGroupId()));
} else {
// old closed group or open group
// legacy group or community
this.groupId = Address.fromSerialized(GroupUtil.getEncodedId(group.get()));
}
} else {

@ -82,7 +82,7 @@ public class IncomingTextMessage implements Parcelable {
if (group.isPresent()) {
SignalServiceGroup groupObject = group.get();
if (groupObject.isNewClosedGroup()) {
if (groupObject.isGroupV2()) {
// new closed group 03..etc..
this.groupId = Address.fromSerialized(Hex.toStringCondensed(groupObject.getGroupId()));
} else {

@ -168,9 +168,9 @@ fun MessageReceiver.cancelTypingIndicatorsIfNeeded(senderPublicKey: String) {
private fun MessageReceiver.handleExpirationTimerUpdate(message: ExpirationTimerUpdate) {
SSKEnvironment.shared.messageExpirationManager.insertExpirationTimerMessage(message)
val isGroupV1 = message.groupPublicKey != null && message.groupPublicKey?.startsWith(IdPrefix.GROUP.value) == false
val isLegacyGroup = message.groupPublicKey != null && message.groupPublicKey?.startsWith(IdPrefix.GROUP.value) == false
if (isNewConfigEnabled && !isGroupV1) return
if (isNewConfigEnabled && !isLegacyGroup) return
val module = MessagingModuleConfiguration.shared
try {

@ -89,7 +89,7 @@ public class SignalServiceGroup {
return groupId;
}
public boolean isNewClosedGroup() {
public boolean isGroupV2() {
return groupId.length == 33 && groupId[0] == 0x03;
}

Loading…
Cancel
Save