diff options
-rw-r--r-- | res/layout/ime.xml | 46 | ||||
-rw-r--r-- | src/us/minak/IMEGestureOverlayView.java | 15 | ||||
-rw-r--r-- | src/us/minak/IMEService.java | 29 | ||||
-rw-r--r-- | src/us/minak/IMEView.java | 107 |
4 files changed, 6 insertions, 191 deletions
diff --git a/res/layout/ime.xml b/res/layout/ime.xml index fc9e80d..10cd8b8 100644 --- a/res/layout/ime.xml +++ b/res/layout/ime.xml @@ -3,29 +3,13 @@ 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" @@ -35,28 +19,4 @@ 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/src/us/minak/IMEGestureOverlayView.java b/src/us/minak/IMEGestureOverlayView.java index 1a88cd6..0676968 100644 --- a/src/us/minak/IMEGestureOverlayView.java +++ b/src/us/minak/IMEGestureOverlayView.java @@ -59,19 +59,8 @@ public class IMEGestureOverlayView extends GestureOverlayView implements OnGestu } } } - private final Paint mPaintRed = new Paint(); - private final Paint mPaintBlue = new Paint(); + public void onDraw(Canvas canvas) { - mPaintRed.setColor(Color.RED); - mPaintBlue.setColor(Color.BLUE); - canvas.drawCircle( - 0F/*(float)(canvas.getWidth()/2.0)*/, - 0F/*(float)(canvas.getHeight()/2.0)*/, - 10F, - mPaintRed); - canvas.drawLine(0, 0, - canvas.getWidth(), - canvas.getHeight(), - mPaintBlue); + // TODO: put things here } } diff --git a/src/us/minak/IMEService.java b/src/us/minak/IMEService.java index 21bd159..587135c 100644 --- a/src/us/minak/IMEService.java +++ b/src/us/minak/IMEService.java @@ -35,17 +35,6 @@ public class IMEService extends InputMethodService { } }); - penboardView.setOnBackspacePressedListener(new OnBackspacePressedListener() { - @Override - public void backspacePressed(boolean isLongClick) { - if (isLongClick) { - deleteLastWord(); - } else { - getCurrentInputConnection().deleteSurroundingText(1, 0); - } - } - }); - mPenboardView = penboardView; return penboardView; } @@ -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 724d69d..99e36cd 100644 --- a/src/us/minak/IMEView.java +++ b/src/us/minak/IMEView.java @@ -13,13 +13,10 @@ package us.minak; import java.util.LinkedList; -import java.util.Locale; import java.util.Queue; import android.content.Context; import android.util.AttributeSet; -import android.view.View; -import android.widget.Button; import android.widget.RelativeLayout; /** @@ -27,15 +24,8 @@ 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 enum ShiftState { - OFF, ON, CAPS_LOCK - }; - public IMEView(Context context, AttributeSet attrs) { super(context, attrs); } @@ -49,118 +39,23 @@ public class IMEView extends RelativeLayout { enterCharacter(character); } }); - - 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); } public void setOnCharacterEnteredListener(StringReciever onCharacterEnteredListener) { 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; - } - }; - - /** - * 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) { - 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); } } |