summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavisLWebb <davislwebb@ymail.com>2014-05-06 22:22:31 -0400
committerDavisLWebb <davislwebb@ymail.com>2014-05-06 22:22:31 -0400
commit5186680f2f185528cd4a0eacc06d28f175d4e58e (patch)
treed265d0bcda45ef980e88092b83bfc46098c9e19f
parent25473b9881d29813f435e00951e5952585adcd34 (diff)
parent44fa9b5b07062c165192a50fea4301e57d3424ba (diff)
Merge branch 'master' of https://github.com/AndrewMurrell/minak
-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.java105
5 files changed, 10 insertions, 181 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 7cdf4fd..2cf7921 100644
--- a/src/us/minak/IMEView.java
+++ b/src/us/minak/IMEView.java
@@ -30,9 +30,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;
@@ -56,10 +53,6 @@ public class IMEView extends RelativeLayout {
return ongoingGesture;
}
- private enum ShiftState {
- OFF, ON, CAPS_LOCK
- };
-
public IMEView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@@ -74,18 +67,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)));
@@ -96,58 +77,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) {
@@ -156,48 +89,12 @@ 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
* The character to enter
*/
private void enterCharacter(String character) {
- //for each circle in circles check to see if the touch was in the circle and apply the meta-key
- switch (mShiftState) {
- case OFF:
- mOnCharacterEnteredListener.putString(character);
- break;
- case ON:
- mOnCharacterEnteredListener.putString(character.toUpperCase(Locale.ENGLISH));
- shift();
- break;
- case CAPS_LOCK:
- mOnCharacterEnteredListener.putString(character.toUpperCase(Locale.ENGLISH));
- break;
- default:
- throw new IllegalArgumentException();
- }
+ mOnCharacterEnteredListener.putString(character);
}
}