summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <shumakl@purdue.edu>2014-05-06 14:16:31 -0400
committerLuke Shumaker <shumakl@purdue.edu>2014-05-06 14:16:31 -0400
commit53846dbc2338c816b29888881969090e52a9c3df (patch)
tree96276898a72696676a568303db5a016f242ceb13
parentc5f779844c5d4a9bc5c5ad72074a28ba5b75c75a (diff)
Use a generic StringReciever interface instead of On*Listener garbage
-rw-r--r--src/us/minak/IMEGestureOverlayView.java6
-rw-r--r--src/us/minak/IMEService.java4
-rw-r--r--src/us/minak/IMEView.java16
-rw-r--r--src/us/minak/OnCharacterEnteredListener.java26
-rw-r--r--src/us/minak/OnGestureRecognizedListener.java26
5 files changed, 13 insertions, 65 deletions
diff --git a/src/us/minak/IMEGestureOverlayView.java b/src/us/minak/IMEGestureOverlayView.java
index 9d98164..d856669 100644
--- a/src/us/minak/IMEGestureOverlayView.java
+++ b/src/us/minak/IMEGestureOverlayView.java
@@ -28,7 +28,7 @@ import android.util.AttributeSet;
public class IMEGestureOverlayView extends GestureOverlayView implements OnGesturePerformedListener {
private static final double SCORE_TRESHOLD = 3.0;
private final GestureLibrary mGestureLibrary;
- private OnGestureRecognizedListener mOnGestureRecognizedListener;
+ private StringReciever mOnGestureRecognizedListener;
public IMEGestureOverlayView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -37,7 +37,7 @@ public class IMEGestureOverlayView extends GestureOverlayView implements OnGestu
addOnGesturePerformedListener(this);
}
- public void setOnGestureRecognizedListener(OnGestureRecognizedListener onGestureRecognizedListener) {
+ public void setOnGestureRecognizedListener(StringReciever onGestureRecognizedListener) {
mOnGestureRecognizedListener = onGestureRecognizedListener;
}
@@ -50,7 +50,7 @@ public class IMEGestureOverlayView extends GestureOverlayView implements OnGestu
}
if (mOnGestureRecognizedListener != null && bestPrediction != null) {
if (bestPrediction.score > SCORE_TRESHOLD) {
- mOnGestureRecognizedListener.gestureRecognized(bestPrediction.name);
+ mOnGestureRecognizedListener.putString(bestPrediction.name);
} else {
clear(false);
}
diff --git a/src/us/minak/IMEService.java b/src/us/minak/IMEService.java
index b99859c..21bd159 100644
--- a/src/us/minak/IMEService.java
+++ b/src/us/minak/IMEService.java
@@ -28,9 +28,9 @@ public class IMEService extends InputMethodService {
public View onCreateInputView() {
final IMEView penboardView = (IMEView) getLayoutInflater().inflate(R.layout.ime, null);
- penboardView.setOnCharacterEnteredListener(new OnCharacterEnteredListener() {
+ penboardView.setOnCharacterEnteredListener(new StringReciever() {
@Override
- public void characterEntered(String character) {
+ public void putString(String character) {
getCurrentInputConnection().commitText(character, 1);
}
});
diff --git a/src/us/minak/IMEView.java b/src/us/minak/IMEView.java
index 93e4ff6..724d69d 100644
--- a/src/us/minak/IMEView.java
+++ b/src/us/minak/IMEView.java
@@ -26,7 +26,7 @@ import android.widget.RelativeLayout;
* Represents the container for the drawing space and the two side panels.
*/
public class IMEView extends RelativeLayout {
- private OnCharacterEnteredListener mOnCharacterEnteredListener;
+ private StringReciever mOnCharacterEnteredListener;
private OnBackspacePressedListener mOnBackspacePressedListener;
private Button mShiftButton;
private ShiftState mShiftState = ShiftState.OFF;
@@ -43,9 +43,9 @@ public class IMEView extends RelativeLayout {
@Override
protected void onFinishInflate() {
IMEGestureOverlayView drawingSpaceView = (IMEGestureOverlayView) findViewById(R.id.drawing_space);
- drawingSpaceView.setOnGestureRecognizedListener(new OnGestureRecognizedListener() {
+ drawingSpaceView.setOnGestureRecognizedListener(new StringReciever() {
@Override
- public void gestureRecognized(String character) {
+ public void putString(String character) {
enterCharacter(character);
}
});
@@ -63,7 +63,7 @@ public class IMEView extends RelativeLayout {
spaceButton.setOnLongClickListener(mButtonLongClickListener);
}
- public void setOnCharacterEnteredListener(OnCharacterEnteredListener onCharacterEnteredListener) {
+ public void setOnCharacterEnteredListener(StringReciever onCharacterEnteredListener) {
mOnCharacterEnteredListener = onCharacterEnteredListener;
}
@@ -89,7 +89,7 @@ public class IMEView extends RelativeLayout {
mOnBackspacePressedListener.backspacePressed(false);
break;
case R.id.space_btn:
- mOnCharacterEnteredListener.characterEntered(" ");
+ mOnCharacterEnteredListener.putString(" ");
break;
default:
throw new IllegalArgumentException();
@@ -150,14 +150,14 @@ public class IMEView extends RelativeLayout {
private void enterCharacter(String character) {
switch (mShiftState) {
case OFF:
- mOnCharacterEnteredListener.characterEntered(character);
+ mOnCharacterEnteredListener.putString(character);
break;
case ON:
- mOnCharacterEnteredListener.characterEntered(character.toUpperCase(Locale.ENGLISH));
+ mOnCharacterEnteredListener.putString(character.toUpperCase(Locale.ENGLISH));
shift();
break;
case CAPS_LOCK:
- mOnCharacterEnteredListener.characterEntered(character.toUpperCase(Locale.ENGLISH));
+ mOnCharacterEnteredListener.putString(character.toUpperCase(Locale.ENGLISH));
break;
default:
throw new IllegalArgumentException();
diff --git a/src/us/minak/OnCharacterEnteredListener.java b/src/us/minak/OnCharacterEnteredListener.java
deleted file mode 100644
index 31b76e9..0000000
--- a/src/us/minak/OnCharacterEnteredListener.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- ********************************************************************************
- * Copyright (c) 2012 Samsung Electronics, Inc.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Inc. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- ********************************************************************************
- */
-
-package us.minak;
-
-/**
- * A simple interface for handling entering a character.
- */
-public interface OnCharacterEnteredListener {
- /**
- * Invoked when a character is entered.
- *
- * @param character
- * The entered character
- */
- void characterEntered(String character);
-}
diff --git a/src/us/minak/OnGestureRecognizedListener.java b/src/us/minak/OnGestureRecognizedListener.java
deleted file mode 100644
index a30e8b8..0000000
--- a/src/us/minak/OnGestureRecognizedListener.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- ********************************************************************************
- * Copyright (c) 2012 Samsung Electronics, Inc.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information of Samsung
- * Electronics, Inc. ("Confidential Information"). You shall not disclose such
- * Confidential Information and shall use it only in accordance with the terms
- * of the license agreement you entered into with Samsung Electronics.
- ********************************************************************************
- */
-
-package us.minak;
-
-/**
- * A simple interface for handling recognizing a gesture.
- */
-public interface OnGestureRecognizedListener {
- /**
- * Invoked when a gesture is recognized.
- *
- * @param character
- * The character represented by the gesture.
- */
- void gestureRecognized(String character);
-}