Skip to content

Commit

Permalink
Misc fixes for CustomKeyboard
Browse files Browse the repository at this point in the history
Several easy unrelated fixes included unused imports, not needed local
variables or unneeded null checks.
  • Loading branch information
svillar committed Dec 21, 2023
1 parent c077b35 commit c34a96c
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import android.content.Context;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
import com.igalia.wolvic.input.Keyboard;
import android.view.KeyEvent;

import java.lang.reflect.Field;
Expand Down Expand Up @@ -67,7 +66,7 @@ public CustomKeyboard (Context context, int layoutTemplateResId, CharSequence ch
}
for (int i = 0; i < characters.length(); i++) {
char c = characters.charAt(i);
int rowIndex = (int)Math.floor(i/columns);
int rowIndex = i / columns;

final Key key = new Key(mRows[rowIndex]);

Expand All @@ -91,9 +90,7 @@ public CustomKeyboard (Context context, int layoutTemplateResId, CharSequence ch
if (keysObj != null && getFieldObject(mRows[rowIndex], "mKeys") instanceof ArrayList) {
@SuppressWarnings("unchecked")
ArrayList<Key> mKeys = (ArrayList<Key>) keysObj;
if (mKeys != null) {
mKeys.add(key);
}
mKeys.add(key);
}
int mTotalWidth = getParentFieldInt(this, "mTotalWidth");
if (x > mTotalWidth) {
Expand Down Expand Up @@ -145,8 +142,7 @@ public static Field getField(Class<?> clazz, String fieldName) {
Class<?> tmpClass = clazz;
do {
try {
Field f = tmpClass.getDeclaredField(fieldName);
return f;
return tmpClass.getDeclaredField(fieldName);
} catch (NoSuchFieldException e) {
tmpClass = tmpClass.getSuperclass();
}
Expand Down Expand Up @@ -188,7 +184,7 @@ protected Key createKeyFromXml(Resources res, Row parent, int x, int y, XmlResou
@Override
public int[] getNearestKeys(int x, int y) {
List<Key> keys = getKeys();
Key[] mKeys = keys.toArray(new Key[keys.size()]);
Key[] mKeys = keys.toArray(new Key[0]);
int i = 0;
for (Key key : mKeys) {
if(key.isInside(x, y))
Expand Down

0 comments on commit c34a96c

Please sign in to comment.