summaryrefslogtreecommitdiff
path: root/src/us
diff options
context:
space:
mode:
authorAndrewMurrell <amurrel@purdue.edu>2014-05-06 22:26:49 -0400
committerAndrewMurrell <amurrel@purdue.edu>2014-05-06 22:26:49 -0400
commitcc0db6ceec33742b018a989d4b9bbf046418ca9f (patch)
tree10dc54fc3d57a4e589dedf6c8f62106bc757216e /src/us
parenta0ac4d4cf9e31bbe019d29ddb6f514a9e3edcc73 (diff)
parent44fa9b5b07062c165192a50fea4301e57d3424ba (diff)
Merge branch 'master' of https://github.com/AndrewMurrell/minak
Conflicts: src/us/minak/IMEView.java
Diffstat (limited to 'src/us')
-rw-r--r--src/us/minak/IMEGestureOverlayView.java6
-rw-r--r--src/us/minak/IMEService.java29
-rw-r--r--src/us/minak/IMEView.java91
3 files changed, 5 insertions, 121 deletions
diff --git a/src/us/minak/IMEGestureOverlayView.java b/src/us/minak/IMEGestureOverlayView.java
index b167c53..7e8867d 100644
--- a/src/us/minak/IMEGestureOverlayView.java
+++ b/src/us/minak/IMEGestureOverlayView.java
@@ -33,6 +33,7 @@ public class IMEGestureOverlayView extends GestureOverlayView implements OnGestu
private final GestureLibrary mGestureLibrary;
private StringReciever mOnGestureRecognizedListener;
public List<MetaCircle> circles = new LinkedList<MetaCircle>();
+ private final Paint mPaint = new Paint();
public IMEGestureOverlayView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -63,9 +64,8 @@ public class IMEGestureOverlayView extends GestureOverlayView implements OnGestu
public void onDraw(Canvas canvas) {
for (MetaCircle circle : circles) {
- final Paint p = new Paint();
- p.setColor(circle.color);
- canvas.drawCircle(circle.x, circle.y, circle.radius, p);
+ mPaint.setColor(circle.color);
+ canvas.drawCircle(circle.x, circle.y, circle.radius, mPaint);
}
}
}
diff --git a/src/us/minak/IMEService.java b/src/us/minak/IMEService.java
index ae12bc2..a0a9ece 100644
--- a/src/us/minak/IMEService.java
+++ b/src/us/minak/IMEService.java
@@ -35,17 +35,6 @@ public class IMEService extends InputMethodService {
}
});
- minakView.setOnBackspacePressedListener(new OnBackspacePressedListener() {
- @Override
- public void backspacePressed(boolean isLongClick) {
- if (isLongClick) {
- deleteLastWord();
- } else {
- getCurrentInputConnection().deleteSurroundingText(1, 0);
- }
- }
- });
-
mIMEView = minakView;
return minakView;
}
@@ -60,22 +49,4 @@ public class IMEService extends InputMethodService {
}
}
}
-
- /**
- * Deletes one word before the cursor.
- */
- private void deleteLastWord() {
- final int charactersToGet = 20;
- final String splitRegexp = " ";
-
- // delete trailing spaces
- while (getCurrentInputConnection().getTextBeforeCursor(1, 0).toString().equals(splitRegexp)) {
- getCurrentInputConnection().deleteSurroundingText(1, 0);
- }
-
- // delete last word letters
- final String[] words = getCurrentInputConnection().getTextBeforeCursor(charactersToGet, 0).toString()
- .split(splitRegexp);
- getCurrentInputConnection().deleteSurroundingText(words[words.length - 1].length(), 0);
- }
}
diff --git a/src/us/minak/IMEView.java b/src/us/minak/IMEView.java
index 0f40325..1b09af9 100644
--- a/src/us/minak/IMEView.java
+++ b/src/us/minak/IMEView.java
@@ -28,9 +28,6 @@ import android.widget.RelativeLayout;
*/
public class IMEView extends RelativeLayout {
private StringReciever mOnCharacterEnteredListener;
- private OnBackspacePressedListener mOnBackspacePressedListener;
- private Button mShiftButton;
- private ShiftState mShiftState = ShiftState.OFF;
private final Queue<Character> mSymbolsQueue = new LinkedList<Character>();
private float x;
@@ -54,10 +51,6 @@ public class IMEView extends RelativeLayout {
return ongoingGesture;
}
- private enum ShiftState {
- OFF, ON, CAPS_LOCK
- };
-
public IMEView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@@ -72,18 +65,6 @@ public class IMEView extends RelativeLayout {
}
});
- mShiftButton = (Button) findViewById(R.id.shift_btn);
- mShiftButton.setOnClickListener(mButtonClickListener);
- mShiftButton.setOnLongClickListener(mButtonLongClickListener);
-
- final Button backspaceButton = (Button) findViewById(R.id.backspace_btn);
- backspaceButton.setOnClickListener(mButtonClickListener);
- backspaceButton.setOnLongClickListener(mButtonLongClickListener);
-
- final Button spaceButton = (Button) findViewById(R.id.space_btn);
- spaceButton.setOnClickListener(mButtonClickListener);
- spaceButton.setOnLongClickListener(mButtonLongClickListener);
-
//dynamic MetaCircle adding stuff here. replace null with Shift or Ctrl or Meta or Alt or Hyper or whatever.
drawingSpaceView.circles.add(new MetaCircle((float)50.0, (float)50.0, (float)20.0, Color.RED, new MetaExpression(null)));
drawingSpaceView.circles.add(new MetaCircle((float)70.0, (float)70.0, (float)20.0, Color.RED, new MetaExpression(null)));
@@ -94,58 +75,10 @@ public class IMEView extends RelativeLayout {
mOnCharacterEnteredListener = onCharacterEnteredListener;
}
- public void setOnBackspacePressedListener(OnBackspacePressedListener onBackspacePressedListener) {
- mOnBackspacePressedListener = onBackspacePressedListener;
- }
-
public Queue<Character> getSymbolsQueue() {
return mSymbolsQueue;
}
- /**
- * Listener handling pressing all buttons.
- */
- private final OnClickListener mButtonClickListener = new OnClickListener() {
- @Override
- public void onClick(View v) {
- switch (v.getId()) {
- case R.id.shift_btn:
- shift();
- break;
- case R.id.backspace_btn:
- mOnBackspacePressedListener.backspacePressed(false);
- break;
- case R.id.space_btn:
- mOnCharacterEnteredListener.putString(" ");
- break;
- default:
- throw new IllegalArgumentException();
- }
- }
- };
-
- /**
- * Listener handling long pressing all buttons.
- */
- private final OnLongClickListener mButtonLongClickListener = new OnLongClickListener() {
- @Override
- public boolean onLongClick(View v) {
- switch (v.getId()) {
- case R.id.shift_btn:
- break;
- case R.id.backspace_btn:
- mOnBackspacePressedListener.backspacePressed(true);
- return true;
- case R.id.space_btn:
- break;
- default:
- throw new IllegalArgumentException();
- }
-
- return false;
- }
- };
-
private final OnTouchListener mOnTouchListener = new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
@@ -154,28 +87,6 @@ public class IMEView extends RelativeLayout {
};
/**
- * Changes shift state to the next one (OFF -> ON -> CAPS LOCK).
- */
- private void shift() {
- switch (mShiftState) {
- case OFF:
- mShiftState = ShiftState.ON;
- //mShiftButton.setBackgroundResource(R.drawable.shift_on);
- break;
- case ON:
- mShiftState = ShiftState.CAPS_LOCK;
- //mShiftButton.setBackgroundResource(R.drawable.shift_caps_lock);
- break;
- case CAPS_LOCK:
- mShiftState = ShiftState.OFF;
- //mShiftButton.setBackgroundResource(R.drawable.shift_off);
- break;
- default:
- throw new IllegalArgumentException();
- }
- }
-
- /**
* Passes the given character to the input service.
*
* @param character
@@ -189,5 +100,7 @@ public class IMEView extends RelativeLayout {
;
}
}
+
+ mOnCharacterEnteredListener.putString(character);
}
}