chore: publish native ui polish release v2.5.3
This commit is contained in:
@@ -912,10 +912,7 @@ public final class BossUi {
|
||||
wrapper.setLayoutParams(wrapperParams);
|
||||
|
||||
TextView metaView = new TextView(context);
|
||||
String metaText = senderLabel;
|
||||
if (!TextUtils.isEmpty(meta)) {
|
||||
metaText = metaText + " · " + meta;
|
||||
}
|
||||
String metaText = buildMessageMetaText(senderLabel, meta, outgoing);
|
||||
metaView.setText(metaText);
|
||||
metaView.setTextSize(11);
|
||||
metaView.setTextColor(context.getColor(R.color.boss_text_soft));
|
||||
@@ -1049,10 +1046,7 @@ public final class BossUi {
|
||||
wrapper.setLayoutParams(wrapperParams);
|
||||
|
||||
TextView metaView = new TextView(context);
|
||||
String metaText = senderLabel;
|
||||
if (!TextUtils.isEmpty(meta)) {
|
||||
metaText = metaText + " · " + meta;
|
||||
}
|
||||
String metaText = buildMessageMetaText(senderLabel, meta, outgoing);
|
||||
metaView.setText(metaText);
|
||||
metaView.setTextSize(11);
|
||||
metaView.setTextColor(context.getColor(R.color.boss_text_soft));
|
||||
@@ -1061,6 +1055,23 @@ public final class BossUi {
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
private static String buildMessageMetaText(
|
||||
String senderLabel,
|
||||
@Nullable String meta,
|
||||
boolean outgoing
|
||||
) {
|
||||
if (outgoing && !TextUtils.isEmpty(meta)) {
|
||||
return meta;
|
||||
}
|
||||
if (TextUtils.isEmpty(meta)) {
|
||||
return senderLabel;
|
||||
}
|
||||
if (TextUtils.isEmpty(senderLabel)) {
|
||||
return meta;
|
||||
}
|
||||
return senderLabel + " · " + meta;
|
||||
}
|
||||
|
||||
private static TextView buildAttachmentPrimaryText(Context context, String text) {
|
||||
TextView primary = new TextView(context);
|
||||
primary.setText(TextUtils.isEmpty(text) ? "未命名附件" : text);
|
||||
|
||||
@@ -2,8 +2,11 @@ package com.hyzq.boss;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
@@ -85,15 +88,13 @@ public class GroupCreateActivity extends BossScreenActivity {
|
||||
? sourceProjectName
|
||||
: threadMeta.optString("threadDisplayName", sourceProjectName == null ? "当前会话" : sourceProjectName);
|
||||
}
|
||||
for (SummaryCardSpec cardSpec : buildHeaderCardSpecs(
|
||||
appendContent(buildHeaderView(
|
||||
hasSourceProject(),
|
||||
sourceProjectId,
|
||||
sourceProjectName,
|
||||
threadMeta,
|
||||
participants
|
||||
)) {
|
||||
appendContent(BossUi.buildCard(this, cardSpec.title, cardSpec.body, cardSpec.meta));
|
||||
}
|
||||
));
|
||||
|
||||
if (rebuildCandidates) {
|
||||
List<JSONObject> selectableConversations = collectSelectableConversationItems(conversationsPayload, sourceProjectId);
|
||||
@@ -121,16 +122,10 @@ public class GroupCreateActivity extends BossScreenActivity {
|
||||
lastCandidateProjectIds.addAll(nextCandidateProjectIds);
|
||||
}
|
||||
|
||||
SummaryCardSpec selectionCard = buildSelectionCardSpec(
|
||||
candidates.size(),
|
||||
selectedProjectIds.size(),
|
||||
hasSourceProject()
|
||||
);
|
||||
appendContent(BossUi.buildCard(
|
||||
appendContent(buildSectionLabel("选择其他线程"));
|
||||
appendContent(BossUi.buildHintPill(
|
||||
this,
|
||||
selectionCard.title,
|
||||
selectionCard.body,
|
||||
selectionCard.meta
|
||||
buildSelectionHintText(candidates.size(), selectedProjectIds.size(), hasSourceProject())
|
||||
));
|
||||
|
||||
candidateListLayout = new LinearLayout(this);
|
||||
@@ -145,16 +140,53 @@ public class GroupCreateActivity extends BossScreenActivity {
|
||||
|
||||
createButton = BossUi.buildPrimaryButton(this, "创建群聊");
|
||||
createButton.setOnClickListener(v -> createGroupChat());
|
||||
appendContent(createButton);
|
||||
|
||||
Button cancelButton = BossUi.buildSecondaryButton(this, "取消");
|
||||
cancelButton.setOnClickListener(v -> finish());
|
||||
appendContent(cancelButton);
|
||||
appendContent(BossUi.buildInlineActionRow(this, cancelButton, createButton));
|
||||
|
||||
setRefreshing(false);
|
||||
updateCreateButtonState();
|
||||
}
|
||||
|
||||
private View buildHeaderView(
|
||||
boolean hasSourceProject,
|
||||
@Nullable String sourceProjectId,
|
||||
@Nullable String sourceProjectName,
|
||||
@Nullable JSONObject threadMeta,
|
||||
@Nullable JSONArray participants
|
||||
) {
|
||||
if (hasSourceProject) {
|
||||
return BossUi.buildSimpleProfileHeader(
|
||||
this,
|
||||
TextUtils.isEmpty(sourceProjectName) ? "当前会话" : sourceProjectName,
|
||||
"从当前会话发起群聊",
|
||||
buildSourceHeaderDetail(sourceProjectId, threadMeta, participants)
|
||||
);
|
||||
}
|
||||
return BossUi.buildSimpleProfileHeader(
|
||||
this,
|
||||
"发起新群聊",
|
||||
"从会话列表直接建群",
|
||||
"至少选择 2 个线程后创建新群"
|
||||
);
|
||||
}
|
||||
|
||||
private TextView buildSectionLabel(String text) {
|
||||
TextView label = new TextView(this);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||
);
|
||||
params.leftMargin = BossUi.dp(this, 16);
|
||||
params.rightMargin = BossUi.dp(this, 16);
|
||||
params.bottomMargin = BossUi.dp(this, 6);
|
||||
label.setLayoutParams(params);
|
||||
label.setText(text);
|
||||
label.setTextSize(13);
|
||||
label.setTextColor(getColor(R.color.boss_text_muted));
|
||||
return label;
|
||||
}
|
||||
|
||||
static List<JSONObject> collectSelectableConversationItems(@Nullable JSONObject conversationsPayload, String sourceProjectId) {
|
||||
List<JSONObject> result = new ArrayList<>();
|
||||
JSONArray conversations = conversationsPayload == null ? null : conversationsPayload.optJSONArray("conversations");
|
||||
@@ -192,65 +224,39 @@ public class GroupCreateActivity extends BossScreenActivity {
|
||||
);
|
||||
}
|
||||
|
||||
static List<SummaryCardSpec> buildHeaderCardSpecs(
|
||||
boolean hasSourceProject,
|
||||
static String buildSourceHeaderDetail(
|
||||
@Nullable String sourceProjectId,
|
||||
@Nullable String sourceProjectName,
|
||||
@Nullable JSONObject threadMeta,
|
||||
@Nullable JSONArray participants
|
||||
) {
|
||||
List<SummaryCardSpec> cards = new ArrayList<>(1);
|
||||
if (hasSourceProject) {
|
||||
String resolvedSourceProjectName = sourceProjectName == null || sourceProjectName.isEmpty()
|
||||
? "当前会话"
|
||||
: sourceProjectName;
|
||||
cards.add(new SummaryCardSpec(
|
||||
resolvedSourceProjectName,
|
||||
buildSourceBody(sourceProjectId, threadMeta, participants),
|
||||
"新群会单独创建,原会话保留"
|
||||
));
|
||||
return cards;
|
||||
}
|
||||
cards.add(new SummaryCardSpec(
|
||||
"从会话中发起群聊",
|
||||
"至少选择 2 个线程,新群会单独创建。",
|
||||
"原有单线程会话会保留"
|
||||
));
|
||||
return cards;
|
||||
return buildSourceBody(sourceProjectId, threadMeta, participants);
|
||||
}
|
||||
|
||||
static SummaryCardSpec buildSelectionCardSpec(
|
||||
static String buildSelectionHintText(
|
||||
int candidateCount,
|
||||
int selectedCount,
|
||||
boolean hasSourceProject
|
||||
) {
|
||||
if (candidateCount <= 0) {
|
||||
return new SummaryCardSpec(
|
||||
"选择其他线程",
|
||||
"当前没有可加入的其他线程",
|
||||
"候选 0 个 · 已选 0 个"
|
||||
);
|
||||
return "当前没有可加入的其他线程";
|
||||
}
|
||||
if (selectedCount <= 0) {
|
||||
return new SummaryCardSpec(
|
||||
"选择其他线程",
|
||||
hasSourceProject ? "至少选择 1 个其他线程" : "至少选择 2 个线程",
|
||||
"候选 " + candidateCount + " 个 · 已选 0 个"
|
||||
);
|
||||
return hasSourceProject ? "至少选择 1 个其他线程" : "至少选择 2 个线程";
|
||||
}
|
||||
return new SummaryCardSpec(
|
||||
"选择其他线程",
|
||||
"继续点选可调整成员",
|
||||
"候选 " + candidateCount + " 个 · 已选 " + selectedCount + " 个"
|
||||
);
|
||||
return "已选 " + selectedCount + " 个线程";
|
||||
}
|
||||
|
||||
private LinearLayout buildCandidateRow(CandidateConversation candidate) {
|
||||
return BossUi.buildConversationRow(
|
||||
LinearLayout row = BossUi.buildConversationRow(
|
||||
this,
|
||||
toCandidateConversationRow(candidate.sourceItem, selectedProjectIds.contains(candidate.projectId)),
|
||||
v -> toggleSelection(candidate.projectId)
|
||||
);
|
||||
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) row.getLayoutParams();
|
||||
params.bottomMargin = BossUi.dp(this, 8);
|
||||
row.setLayoutParams(params);
|
||||
row.setPadding(BossUi.dp(this, 12), BossUi.dp(this, 12), BossUi.dp(this, 12), BossUi.dp(this, 12));
|
||||
return row;
|
||||
}
|
||||
|
||||
private void toggleSelection(String projectId) {
|
||||
@@ -399,7 +405,7 @@ public class GroupCreateActivity extends BossScreenActivity {
|
||||
String folderName = threadMeta == null ? "" : threadMeta.optString("folderName", "");
|
||||
String resolvedFolderName = folderName.isEmpty() ? "未命名文件夹" : folderName;
|
||||
String resolvedThreadId = threadId == null || threadId.isEmpty() ? "未命名线程" : threadId;
|
||||
return "来源线程 " + resolvedThreadId
|
||||
return resolvedThreadId
|
||||
+ " · "
|
||||
+ resolvedFolderName
|
||||
+ " · "
|
||||
@@ -407,18 +413,6 @@ public class GroupCreateActivity extends BossScreenActivity {
|
||||
+ " 个参与线程";
|
||||
}
|
||||
|
||||
static final class SummaryCardSpec {
|
||||
final String title;
|
||||
final String body;
|
||||
final String meta;
|
||||
|
||||
SummaryCardSpec(String title, String body, String meta) {
|
||||
this.title = title;
|
||||
this.body = body;
|
||||
this.meta = meta;
|
||||
}
|
||||
}
|
||||
|
||||
private static final class CandidateConversation {
|
||||
private final String projectId;
|
||||
private final JSONObject sourceItem;
|
||||
|
||||
Reference in New Issue
Block a user