1
0
Fork 0

code cleanup

This commit is contained in:
sspanak 2025-02-06 15:02:11 +02:00 committed by Dimo Karaivanov
parent f84c21dea8
commit f6a74fc4f9
2 changed files with 25 additions and 9 deletions

View file

@ -39,29 +39,27 @@ public class SoftKeyPunctuation extends SoftKey {
return "*".equals(keyChar) ? "" : keyChar;
}
private String getKeyChar() {
if (!validateTT9Handler()) {
return "";
}
protected String getKeyChar() {
int keyId = getId();
if (keyId == R.id.soft_key_punctuation_1 || keyId == R.id.soft_key_punctuation_201) {
if (keyId == R.id.soft_key_punctuation_1) {
return getKey1Char();
} else if (keyId == R.id.soft_key_punctuation_2 || keyId == R.id.soft_key_punctuation_202) {
} else if (keyId == R.id.soft_key_punctuation_2) {
return getKey2Char();
}
return "";
}
private String getKey1Char() {
protected String getKey1Char() {
if (tt9 == null) return "";
if (tt9.isInputModePhone()) return "*";
if (tt9.isInputModeNumeric()) return ",";
return "!";
}
private String getKey2Char() {
protected String getKey2Char() {
if (tt9 == null) return "";
if (tt9.isInputModePhone()) return "#";
if (tt9.isInputModeNumeric()) return ".";

View file

@ -3,9 +3,27 @@ package io.github.sspanak.tt9.ui.main.keys;
import android.content.Context;
import android.util.AttributeSet;
import io.github.sspanak.tt9.R;
public class SoftKeyPunctuationShort extends SoftKeyPunctuation {
public SoftKeyPunctuationShort(Context context) { super(context); }
public SoftKeyPunctuationShort(Context context, AttributeSet attrs) { super(context, attrs); }
public SoftKeyPunctuationShort(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); }
@Override protected boolean isHiddenWhenLongSpace() { return false; }
protected String getKeyChar() {
if (!validateTT9Handler()) {
return "";
}
int keyId = getId();
if (keyId == R.id.soft_key_punctuation_201) {
return getKey1Char();
} else if (keyId == R.id.soft_key_punctuation_202) {
return getKey2Char();
}
return super.getKeyChar();
}
}