style: align group creation list with conversations
This commit is contained in:
@@ -114,11 +114,7 @@ public class GroupCreateActivity extends BossScreenActivity {
|
||||
for (JSONObject item : selectableConversations) {
|
||||
CandidateConversation candidate = new CandidateConversation(
|
||||
item.optString("projectId", ""),
|
||||
item.optString("projectTitle", item.optString("threadTitle", "未命名会话")),
|
||||
item.optString("folderLabel", ""),
|
||||
item.optString("lastMessagePreview", item.optString("preview", "")),
|
||||
item.optString("latestReplyLabel", ""),
|
||||
false
|
||||
item
|
||||
);
|
||||
nextCandidates.add(candidate);
|
||||
nextCandidateProjectIds.add(candidate.projectId);
|
||||
@@ -191,20 +187,26 @@ public class GroupCreateActivity extends BossScreenActivity {
|
||||
return result;
|
||||
}
|
||||
|
||||
static WechatSurfaceMapper.ConversationRow toCandidateConversationRow(JSONObject item, boolean selected) {
|
||||
return new WechatSurfaceMapper.ConversationRow(
|
||||
item.optString("projectTitle", item.optString("threadTitle", "未命名会话")),
|
||||
item.optString("folderLabel", ""),
|
||||
item.optString("lastMessagePreview", item.optString("preview", "")),
|
||||
item.optString("latestReplyLabel", ""),
|
||||
0,
|
||||
selected ? "已选" : "",
|
||||
0,
|
||||
false,
|
||||
"",
|
||||
"",
|
||||
new WechatSurfaceMapper.GroupAvatarMember[0]
|
||||
);
|
||||
}
|
||||
|
||||
private LinearLayout buildCandidateRow(CandidateConversation candidate) {
|
||||
boolean selected = selectedProjectIds.contains(candidate.projectId);
|
||||
String badge = selected ? "已选" : "未选";
|
||||
String subtitle = candidate.folderLabel.isEmpty() ? candidate.latestReplyLabel : candidate.folderLabel;
|
||||
String meta = candidate.preview;
|
||||
if (!candidate.latestReplyLabel.isEmpty() && !candidate.latestReplyLabel.equals(candidate.preview)) {
|
||||
meta = candidate.latestReplyLabel + (meta.isEmpty() ? "" : " · " + meta);
|
||||
}
|
||||
return BossUi.buildListRow(
|
||||
return BossUi.buildConversationRow(
|
||||
this,
|
||||
candidate.title,
|
||||
subtitle,
|
||||
meta,
|
||||
badge,
|
||||
toCandidateConversationRow(candidate.sourceItem, selectedProjectIds.contains(candidate.projectId)),
|
||||
v -> toggleSelection(candidate.projectId)
|
||||
);
|
||||
}
|
||||
@@ -369,26 +371,14 @@ public class GroupCreateActivity extends BossScreenActivity {
|
||||
|
||||
private static final class CandidateConversation {
|
||||
private final String projectId;
|
||||
private final String title;
|
||||
private final String folderLabel;
|
||||
private final String preview;
|
||||
private final String latestReplyLabel;
|
||||
private final boolean isGroup;
|
||||
private final JSONObject sourceItem;
|
||||
|
||||
private CandidateConversation(
|
||||
String projectId,
|
||||
String title,
|
||||
String folderLabel,
|
||||
String preview,
|
||||
String latestReplyLabel,
|
||||
boolean isGroup
|
||||
JSONObject sourceItem
|
||||
) {
|
||||
this.projectId = projectId;
|
||||
this.title = title;
|
||||
this.folderLabel = folderLabel;
|
||||
this.preview = preview;
|
||||
this.latestReplyLabel = latestReplyLabel;
|
||||
this.isGroup = isGroup;
|
||||
this.sourceItem = sourceItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,6 +93,28 @@ public class GroupCreateActivityTest {
|
||||
assertTrue(GroupCreateActivity.canCreateGroupChat(false, false, linkedSet("thread-1", "thread-2"), false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toCandidateConversationRow_usesConversationCardChromeAndSelectedBadge() {
|
||||
JSONObject item = new StubJSONObject()
|
||||
.withString("projectId", "thread-1")
|
||||
.withString("projectTitle", "北区试产线回归")
|
||||
.withString("folderLabel", "Mac Studio")
|
||||
.withString("lastMessagePreview", "认证链路交接线程")
|
||||
.withString("latestReplyLabel", "09:26")
|
||||
.withInt("unreadCount", 3)
|
||||
.withInt("activityIconCount", 2);
|
||||
|
||||
WechatSurfaceMapper.ConversationRow row = GroupCreateActivity.toCandidateConversationRow(item, true);
|
||||
|
||||
assertEquals("北区试产线回归", row.threadTitle);
|
||||
assertEquals("Mac Studio", row.folderLabel);
|
||||
assertEquals("认证链路交接线程", row.lastMessagePreview);
|
||||
assertEquals("09:26", row.timeLabel);
|
||||
assertEquals("已选", row.topPinnedLabel);
|
||||
assertEquals(0, row.unreadCount);
|
||||
assertEquals(0, row.activityIconCount);
|
||||
}
|
||||
|
||||
private static Set<String> linkedSet(String... values) {
|
||||
Set<String> result = new LinkedHashSet<>();
|
||||
for (String value : values) {
|
||||
@@ -114,6 +136,11 @@ public class GroupCreateActivityTest {
|
||||
return this;
|
||||
}
|
||||
|
||||
StubJSONObject withInt(String key, int value) {
|
||||
values.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
StubJSONObject withObjectArray(String key, JSONObject... entries) {
|
||||
values.put(key, new StubJSONArray(entries));
|
||||
return this;
|
||||
@@ -131,6 +158,12 @@ public class GroupCreateActivityTest {
|
||||
return value instanceof Boolean ? (Boolean) value : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int optInt(String key, int defaultValue) {
|
||||
Object value = values.get(key);
|
||||
return value instanceof Integer ? (Integer) value : defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray optJSONArray(String key) {
|
||||
Object value = values.get(key);
|
||||
|
||||
Reference in New Issue
Block a user