fix(输入法): 修复光标间隙并扩大26键及明确大小写切换

这个提交包含在:
sydxky 于 2026-11-14 19:37:32 +08:00 提交
1 父节点 b95e7caae7
当前提交 100757f684
35 个文件已更改
+675 -243

没有与搜索条件相匹配的文件

@@ -77,4 +77,25 @@ public class SurfaceRegressionTest {
finally{controller.close();}
});
}
@Test public void caseSwitchTypesBothCasesInsideWatchBounds(){
ui(()->{
EditText editor=new EditText(context());KeyboardController controller=session(editor,InputType.TYPE_CLASS_TEXT);
try{
controller.action("mode:en");KeyboardSurface surface=controller.surface;
int[] widths={466,467,466};String[] keys={"q","Q","q"};String[] switches={"大写","小写"};
for(int step=0;step<3;step++){
int width=widths[step];surface.measure(View.MeasureSpec.makeMeasureSpec(width,View.MeasureSpec.EXACTLY),View.MeasureSpec.makeMeasureSpec(466,View.MeasureSpec.EXACTLY));surface.layout(0,0,width,466);
View key=find(surface,keys[step]);assertNotNull(key);assertTrue(key.performClick());
for(int i=0;i<surface.getChildCount();i++){
View child=surface.getChildAt(i);assertTrue(child.getLeft()>=0&&child.getTop()>=0&&child.getRight()<=width&&child.getBottom()<=466);
if(context().getResources().getConfiguration().isScreenRound()&&child instanceof android.widget.Button){
for(int x:new int[]{child.getLeft(),child.getRight()})for(int y:new int[]{child.getTop(),child.getBottom()})assertTrue("Button corners stay inside the round screen",Math.hypot(x-width/2.0,y-233)<=width/2.0-1);
}
}
if(step<2){View toggle=find(surface,switches[step]);assertNotNull(toggle);assertTrue(toggle.performClick());}
}
assertEquals("qQq",editor.getText().toString());assertFalse(controller.state.upper);
}finally{controller.close();}
});
}
}
@@ -107,6 +107,7 @@ final class KeyboardSurface extends ViewGroup {
float previewY=top+29;
String preview=state.secret?"私密输入":state.preview.isEmpty()?"开始输入…":state.preview;
TextView previewView=label("preview",preview,21,INK);previewView.setMaxLines(1);previewView.setEllipsize(android.text.TextUtils.TruncateAt.START);
previewView.setLetterSpacing(0f);
previewView.setOnClickListener(v->actions.action("tools"));previewView.setContentDescription("编辑光标");
float pi=inset(previewY,30);place(previewView,pi,previewY,410-2*pi,30);
if(state.expanded) { buildCandidates(previewY+38);return; }
@@ -137,10 +138,11 @@ final class KeyboardSurface extends ViewGroup {
}
float keyHeight=captions.length==4?36:49;
// Hide an unused suggestion strip in direct entry modes to enlarge the keys.
if(!isChinese()){keyHeight=captions.length==4?43:58;}
if(!isChinese()){keyHeight=captions.length==4?43:66;}
else if(state.mode.equals("py")){keyHeight=55;}
for(int i=0;i<captions.length;i++)row(captions[i],values[i],keyY+i*(keyHeight+4),keyHeight,captions[i].length>=7?21:24);
float modeY=keyY+captions.length*(keyHeight+4)+3;
row(new String[]{"九宫","26键","14键",state.upper?"ABC":"abc","123","符号"},new String[]{"mode:t9","mode:py","mode:14","mode:en","mode:num","mode:sym"},modeY,27,13);
row(new String[]{"九宫","26键","14键",state.mode.equals("en")?(state.upper?"小写":"大写"):"abc","123","符号"},new String[]{"mode:t9","mode:py","mode:14","mode:en","mode:num","mode:sym"},modeY,27,13);
bottom(modeY+34,false);
}finally{
java.util.Iterator<Map.Entry<String,View>> iterator=children.entrySet().iterator();