Skip to content

Commit 72e5a49

Browse files
committed
fix: switch hide_comment not works
1 parent 627bc40 commit 72e5a49

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

app/src/main/java/com/osfans/trime/ime/symbol/CandidateAdapter.java

+11-6
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public class CandidateAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
3939
private PositionType textPosition, commentPosition;
4040
private static int COMMENT_UNKNOW = 0, COMMENT_TOP = 1, COMMENT_DOWN = 2, COMMENT_RIGHT = 3;
4141
private static int comment_position;
42+
private static boolean hide_comment;
4243

4344
public CandidateAdapter(Context context) {
4445
myContext = context;
@@ -76,11 +77,15 @@ public void configStyle(int keyMarginX, int keyMarginTop) {
7677
textColor = config.getLiquidColor("long_text_color");
7778
if (textColor == null) textColor = config.getLiquidColor("key_text_color");
7879

79-
comment_position = config.getInt("comment_position");
80-
if (comment_position == COMMENT_UNKNOW) {
81-
comment_position = config.getBoolean("comment_on_top") ? COMMENT_TOP : COMMENT_RIGHT;
80+
hide_comment = Rime.getOption("_hide_comment");
81+
if (hide_comment) {
82+
comment_position = COMMENT_RIGHT;
83+
} else {
84+
comment_position = config.getInt("comment_position");
85+
if (comment_position == COMMENT_UNKNOW) {
86+
comment_position = config.getBoolean("comment_on_top") ? COMMENT_TOP : COMMENT_RIGHT;
87+
}
8288
}
83-
8489
textSize = config.getFloat("candidate_text_size");
8590

8691
background =
@@ -132,8 +137,8 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int in
132137
if (textFont != null) itemViewHold.textView1.setTypeface(textFont);
133138

134139
String text = candidates[index].text;
135-
String comment = candidates[index].comment;
136-
if (comment == null) comment = "";
140+
String comment = "";
141+
if (!hide_comment && candidates[index].comment != null) comment = candidates[index].comment;
137142

138143
if (text.length() > 300) itemViewHold.textView1.setText(text.substring(0, 300));
139144
else itemViewHold.textView1.setText(text);

app/src/main/java/com/osfans/trime/ime/text/Candidate.java

+5-7
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,12 @@ private void updateCandidateWidth() {
306306
break;
307307
}
308308
}
309-
309+
String comment = null, text = candidates[n].text;
310310
float candidateWidth =
311-
graphicUtils.measureText(candidatePaint, candidates[n].text, candidateFont)
312-
+ 2 * candidatePadding;
311+
graphicUtils.measureText(candidatePaint, text, candidateFont) + 2 * candidatePadding;
312+
313313
if (shouldShowComment) {
314-
String comment = candidates[n].comment;
314+
comment = candidates[n].comment;
315315
if (!TextUtils.isEmpty(comment)) {
316316
float commentWidth = graphicUtils.measureText(commentPaint, comment, commentFont);
317317
candidateWidth =
@@ -333,9 +333,7 @@ private void updateCandidateWidth() {
333333

334334
computedCandidates.add(
335335
new ComputedCandidate.Word(
336-
candidates[n].text,
337-
candidates[n].comment,
338-
new Rect(x, 0, (int) (x + candidateWidth), getMeasuredHeight())));
336+
text, comment, new Rect(x, 0, (int) (x + candidateWidth), getMeasuredHeight())));
339337
x += candidateWidth + candidateSpacing;
340338
}
341339
if (Rime.hasLeft()) {

0 commit comments

Comments
 (0)