Skip to content

Commit 33d4502

Browse files
feat: Migrate scope dialog to compose and also migrate ProfileActivity away from adapter to mutableList
AI-assistant: Claude Code v2.1.74 (Claude Sonnet 4.6) Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
1 parent e678bce commit 33d4502

7 files changed

Lines changed: 439 additions & 592 deletions

File tree

app/src/main/java/com/nextcloud/talk/profile/AvatarSection.kt

Lines changed: 91 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import androidx.compose.ui.draw.clip
2929
import androidx.compose.ui.res.painterResource
3030
import androidx.compose.ui.res.stringResource
3131
import androidx.compose.ui.text.style.TextOverflow
32+
import androidx.compose.ui.unit.Dp
3233
import androidx.compose.ui.unit.dp
3334
import androidx.compose.ui.viewinterop.AndroidView
3435
import com.nextcloud.talk.R
@@ -41,116 +42,103 @@ internal fun AvatarSection(
4142
isLandscape: Boolean,
4243
modifier: Modifier = Modifier
4344
) {
44-
val avatarSize = if (isLandscape) 72.dp else 96.dp
45+
if (isLandscape) {
46+
AvatarSectionLandscape(state, callbacks, modifier)
47+
} else {
48+
AvatarSectionPortrait(state, callbacks, modifier)
49+
}
50+
}
4551

46-
@Composable
47-
fun AvatarImage() {
48-
key(state.currentUser?.userId, state.avatarRefreshKey) {
49-
AndroidView(
50-
factory = { ctx ->
51-
ImageView(ctx).apply {
52-
transitionName = "userAvatar.transitionTag"
53-
contentDescription = ctx.getString(R.string.avatar)
54-
}.also { imageView ->
55-
DisplayUtils.loadAvatarImage(
56-
state.currentUser,
57-
imageView,
58-
state.avatarRefreshKey > 0
59-
)
60-
}
61-
},
62-
modifier = Modifier
63-
.size(avatarSize)
64-
.clip(CircleShape)
65-
)
66-
}
52+
@Composable
53+
private fun AvatarImage(state: ProfileUiState, avatarSize: Dp) {
54+
key(state.currentUser?.userId, state.avatarRefreshKey) {
55+
AndroidView(
56+
factory = { ctx ->
57+
ImageView(ctx).apply {
58+
transitionName = "userAvatar.transitionTag"
59+
contentDescription = ctx.getString(R.string.avatar)
60+
}.also { imageView ->
61+
DisplayUtils.loadAvatarImage(state.currentUser, imageView, state.avatarRefreshKey > 0)
62+
}
63+
},
64+
modifier = Modifier.size(avatarSize).clip(CircleShape)
65+
)
6766
}
67+
}
6868

69-
if (isLandscape) {
70-
// Landscape: avatar on the left, name + base URL inline to its right
71-
Column(modifier = modifier.padding(16.dp)) {
72-
Row(verticalAlignment = Alignment.Top) {
73-
AvatarImage()
74-
Spacer(modifier = Modifier.width(16.dp))
75-
Column {
76-
if (state.displayName.isNotEmpty()) {
77-
Text(
78-
text = state.displayName,
79-
style = MaterialTheme.typography.titleLarge,
80-
maxLines = 1,
81-
overflow = TextOverflow.Ellipsis
82-
)
83-
}
84-
if (state.baseUrl.isNotEmpty()) {
85-
Text(
86-
text = state.baseUrl,
87-
style = MaterialTheme.typography.bodyMedium,
88-
color = MaterialTheme.colorScheme.onSurfaceVariant,
89-
maxLines = 1,
90-
overflow = TextOverflow.Ellipsis,
91-
modifier = Modifier.padding(top = 2.dp)
92-
)
93-
}
69+
@Composable
70+
private fun AvatarSectionLandscape(state: ProfileUiState, callbacks: ProfileCallbacks, modifier: Modifier) {
71+
Column(modifier = modifier.padding(16.dp)) {
72+
Row(verticalAlignment = Alignment.Top) {
73+
AvatarImage(state, 72.dp)
74+
Spacer(modifier = Modifier.width(16.dp))
75+
Column {
76+
if (state.displayName.isNotEmpty()) {
77+
Text(
78+
text = state.displayName,
79+
style = MaterialTheme.typography.titleLarge,
80+
maxLines = 1,
81+
overflow = TextOverflow.Ellipsis
82+
)
83+
}
84+
if (state.baseUrl.isNotEmpty()) {
85+
Text(
86+
text = state.baseUrl,
87+
style = MaterialTheme.typography.bodyMedium,
88+
color = MaterialTheme.colorScheme.onSurfaceVariant,
89+
maxLines = 1,
90+
overflow = TextOverflow.Ellipsis,
91+
modifier = Modifier.padding(top = 2.dp)
92+
)
9493
}
95-
}
96-
if (state.showAvatarButtons) {
97-
AvatarButtonsRow(
98-
callbacks = callbacks,
99-
modifier = Modifier.padding(top = 8.dp, start = 40.dp)
100-
)
101-
}
102-
if (state.showProfileEnabledCard) {
103-
ProfileEnabledCard(
104-
isEnabled = state.isProfileEnabled,
105-
onCheckedChange = callbacks.onProfileEnabledChange,
106-
modifier = Modifier.padding(vertical = 8.dp)
107-
)
10894
}
10995
}
110-
} else {
111-
// Portrait: everything stacked and centred
112-
Column(
113-
modifier = modifier.padding(top = 16.dp),
114-
horizontalAlignment = Alignment.CenterHorizontally
115-
) {
116-
AvatarImage()
117-
118-
if (state.displayName.isNotEmpty()) {
119-
Spacer(modifier = Modifier.height(8.dp))
120-
Text(
121-
text = state.displayName,
122-
style = MaterialTheme.typography.titleLarge,
123-
maxLines = 1,
124-
overflow = TextOverflow.Ellipsis,
125-
modifier = Modifier.padding(horizontal = 16.dp)
126-
)
127-
}
128-
129-
if (state.baseUrl.isNotEmpty()) {
130-
Text(
131-
text = state.baseUrl,
132-
style = MaterialTheme.typography.bodyMedium,
133-
color = MaterialTheme.colorScheme.onSurfaceVariant,
134-
maxLines = 2,
135-
overflow = TextOverflow.Ellipsis,
136-
modifier = Modifier.padding(horizontal = 16.dp, vertical = 2.dp)
137-
)
138-
}
139-
140-
if (state.showAvatarButtons) {
141-
AvatarButtonsRow(
142-
callbacks = callbacks,
143-
modifier = Modifier.padding(top = 8.dp, bottom = 8.dp)
144-
)
145-
}
96+
if (state.showAvatarButtons) {
97+
AvatarButtonsRow(callbacks = callbacks, modifier = Modifier.padding(top = 8.dp, start = 40.dp))
98+
}
99+
if (state.showProfileEnabledCard) {
100+
ProfileEnabledCard(
101+
isEnabled = state.isProfileEnabled,
102+
onCheckedChange = callbacks.onProfileEnabledChange,
103+
modifier = Modifier.padding(vertical = 8.dp)
104+
)
105+
}
106+
}
107+
}
146108

147-
if (state.showProfileEnabledCard) {
148-
ProfileEnabledCard(
149-
isEnabled = state.isProfileEnabled,
150-
onCheckedChange = callbacks.onProfileEnabledChange,
151-
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp)
152-
)
153-
}
109+
@Composable
110+
private fun AvatarSectionPortrait(state: ProfileUiState, callbacks: ProfileCallbacks, modifier: Modifier) {
111+
Column(modifier = modifier.padding(top = 16.dp), horizontalAlignment = Alignment.CenterHorizontally) {
112+
AvatarImage(state, 96.dp)
113+
if (state.displayName.isNotEmpty()) {
114+
Spacer(modifier = Modifier.height(8.dp))
115+
Text(
116+
text = state.displayName,
117+
style = MaterialTheme.typography.titleLarge,
118+
maxLines = 1,
119+
overflow = TextOverflow.Ellipsis,
120+
modifier = Modifier.padding(horizontal = 16.dp)
121+
)
122+
}
123+
if (state.baseUrl.isNotEmpty()) {
124+
Text(
125+
text = state.baseUrl,
126+
style = MaterialTheme.typography.bodyMedium,
127+
color = MaterialTheme.colorScheme.onSurfaceVariant,
128+
maxLines = 2,
129+
overflow = TextOverflow.Ellipsis,
130+
modifier = Modifier.padding(horizontal = 16.dp, vertical = 2.dp)
131+
)
132+
}
133+
if (state.showAvatarButtons) {
134+
AvatarButtonsRow(callbacks = callbacks, modifier = Modifier.padding(top = 8.dp, bottom = 8.dp))
135+
}
136+
if (state.showProfileEnabledCard) {
137+
ProfileEnabledCard(
138+
isEnabled = state.isProfileEnabled,
139+
onCheckedChange = callbacks.onProfileEnabledChange,
140+
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp)
141+
)
154142
}
155143
}
156144
}

0 commit comments

Comments
 (0)