Fix most inspection errors

This commit is contained in:
2024-10-10 21:11:47 +02:00
parent 563fb02d1f
commit 1da4ffbc17
2 changed files with 19 additions and 26 deletions
@@ -31,7 +31,7 @@ public class TitanboardIME extends InputMethodService {
public void onCreate() {
super.onCreate();
mKeymap = new HashMap<>();
mVibrator = (Vibrator) getBaseContext().getSystemService(getBaseContext().VIBRATOR_SERVICE);
mVibrator = (Vibrator) getBaseContext().getSystemService(VIBRATOR_SERVICE);
XmlPullParser parser = getResources().getXml(R.xml.keymap_titan);
int code = 0, value = 0, valueAlt = 0;
@@ -41,12 +41,18 @@ public class TitanboardIME extends InputMethodService {
if (type == XmlPullParser.START_TAG && parser.getName().equals("key")) {
for (int i = 0; i < parser.getAttributeCount(); ++i) {
String attr = parser.getAttributeName(i);
if (attr.equals("code")) {
code = Integer.parseInt(parser.getAttributeValue(i));
} else if (attr.equals("value")) {
value = Integer.parseInt(String.valueOf(parser.getAttributeValue(i).codePointAt(0)));
} else if (attr.equals("valueAlt")) {
valueAlt = Integer.parseInt(String.valueOf(parser.getAttributeValue(i).codePointAt(0)));
switch (attr) {
case "code":
code = Integer.parseInt(parser.getAttributeValue(i));
break;
case "value":
value = Integer.parseInt(String.valueOf(parser.getAttributeValue(i)
.codePointAt(0)));
break;
case "valueAlt":
valueAlt = Integer.parseInt(String.valueOf(
parser.getAttributeValue(i).codePointAt(0)));
break;
}
}
} else if (type == XmlPullParser.END_TAG && parser.getName().equals("key")) {
@@ -90,19 +96,18 @@ public class TitanboardIME extends InputMethodService {
return false;
// If it's the backspace key, we remove one character.
case KeyEvent.KEYCODE_DEL:
CharSequence selection = conn.getSelectedText(0);
conn.deleteSurroundingText(1, 0);
adjustMetaKeyStateAfterKeypress(keyCode, event);
adjustMetaKeyStateAfterKeypress();
return true;
case KeyEvent.KEYCODE_SPACE:
conn.commitText(" ", 1);
adjustMetaKeyStateAfterKeypress(keyCode, event);
adjustMetaKeyStateAfterKeypress();
return true;
default:
String key = getKey(keyCode);
if (key != null) {
conn.commitText(getKey(keyCode), 1);
adjustMetaKeyStateAfterKeypress(keyCode, event);
adjustMetaKeyStateAfterKeypress();
return true;
} else {
return false;
@@ -111,7 +116,7 @@ public class TitanboardIME extends InputMethodService {
}
public boolean onKeyUp(int keyCode, KeyEvent event) {
updateMetaKeyStateUp(keyCode, event);
updateMetaKeyStateUp(keyCode);
updateMetaStateTextView();
return false;
}
@@ -145,7 +150,7 @@ public class TitanboardIME extends InputMethodService {
}
}
public void updateMetaKeyStateUp(int keyCode, KeyEvent event) {
public void updateMetaKeyStateUp(int keyCode) {
switch (keyCode) {
case KeyEvent.KEYCODE_ALT_LEFT:
case KeyEvent.KEYCODE_ALT_RIGHT:
@@ -172,7 +177,7 @@ public class TitanboardIME extends InputMethodService {
}
}
public void adjustMetaKeyStateAfterKeypress(int keyCode, KeyEvent event) {
public void adjustMetaKeyStateAfterKeypress() {
if (mMetaKeyLatched != MetaKey.NONE) {
mMetaKeyLatched = MetaKey.NONE;
} else if (mMetaKeyPressed != MetaKey.NONE) {
@@ -244,10 +249,6 @@ public class TitanboardIME extends InputMethodService {
}
}
public void onViewInputSettingsClick(View v) {
}
public void onInputViewExtraKeyClick(View v) {
int visibility = mInputView.findViewById(R.id.extra_view).getVisibility();
Button key = (Button) v;
@@ -260,13 +261,6 @@ public class TitanboardIME extends InputMethodService {
}
}
public void onInputViewDelKeyClick(View v) {
InputConnection conn = getCurrentInputConnection();
if (conn != null) {
conn.deleteSurroundingText(1, 0);
}
}
public void onInputViewKeyClick(View v) {
Button key = (Button) v;
InputConnection conn = getCurrentInputConnection();
-1
View File
@@ -1,5 +1,4 @@
<resources>
<string name="app_name">Titanboard</string>
<string name="ime_label">Titanboard</string>
<string name="more_label">More…</string>
</resources>