summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/layout/ime.xml49
-rw-r--r--res/values/colors.xml2
-rw-r--r--src/us/minak/IMEGestureOverlayView.java6
-rw-r--r--src/us/minak/IMEService.java29
-rw-r--r--src/us/minak/IMEView.java91
5 files changed, 11 insertions, 166 deletions
diff --git a/res/layout/ime.xml b/res/layout/ime.xml
index fc9e80d..83be9d2 100644
--- a/res/layout/ime.xml
+++ b/res/layout/ime.xml
@@ -3,60 +3,21 @@
android:layout_width="match_parent"
android:layout_height="match_parent" >
- <LinearLayout
- android:id="@+id/left_panel"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:orientation="vertical" >
-
- <Button
- android:id="@+id/shift_btn"
- android:text="@string/button_shift"
- android:layout_width="85dp"
- android:layout_height="85dp"
- android:layout_marginBottom="10dp"
- android:layout_marginTop="5dp" />
- </LinearLayout>
-
<us.minak.IMEGestureOverlayView
android:id="@+id/drawing_space"
- android:layout_width="wrap_content"
+
+ android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_centerInParent="true"
- android:layout_toLeftOf="@+id/right_panel"
- android:layout_toRightOf="@+id/left_panel"
+
android:fadeDuration="300"
android:fadeEnabled="true"
android:fadeOffset="200"
- android:gestureColor="#000"
+
+ android:gestureColor="@color/gesture_color"
android:gestureStrokeAngleThreshold="0.0"
android:gestureStrokeLengthThreshold="0.0"
android:gestureStrokeSquarenessThreshold="0.0"
android:gestureStrokeType="multiple" />
- <LinearLayout
- android:id="@+id/right_panel"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
- android:orientation="vertical" >
-
- <Button
- android:id="@+id/backspace_btn"
- android:text="@string/button_backspace"
- android:layout_width="85dp"
- android:layout_height="85dp"
- android:layout_marginBottom="5dp"
- android:layout_marginTop="10dp" />
-
- <Button
- android:id="@+id/space_btn"
- android:text="@string/button_space"
- android:layout_width="85dp"
- android:layout_height="85dp"
- android:layout_marginBottom="10dp"
- android:layout_marginTop="5dp" />
- </LinearLayout>
-
</us.minak.IMEView>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index ca6e02a..9302529 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
- <color name="gesture_color">#FFFFFF00</color>
+ <color name="gesture_color">#CC5B59AB</color>
</resources>
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);
}
}