From 1da4ffbc17bddfc2f77e0d0b8e50ce4e938841f6 Mon Sep 17 00:00:00 2001 From: Emil Kosz Date: Thu, 10 Oct 2024 21:11:47 +0200 Subject: [PATCH] Fix most inspection errors --- .../eu/titanboard/TitanboardIME.java | 44 ++++++++----------- app/src/main/res/values/strings.xml | 1 - 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/cfpi_fpsi/eu/titanboard/TitanboardIME.java b/app/src/main/java/cfpi_fpsi/eu/titanboard/TitanboardIME.java index 0f5feb5..8d212fb 100644 --- a/app/src/main/java/cfpi_fpsi/eu/titanboard/TitanboardIME.java +++ b/app/src/main/java/cfpi_fpsi/eu/titanboard/TitanboardIME.java @@ -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(); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1c6e4e9..7c4ff72 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,5 +1,4 @@ Titanboard Titanboard - More… \ No newline at end of file