diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/us/minak/IMEService.java | 7 | ||||
-rw-r--r-- | src/us/minak/IMEView.java | 23 | ||||
-rw-r--r-- | src/us/minak/Minak.java | 38 | ||||
-rw-r--r-- | src/us/minak/MinakView.java | 102 | ||||
-rw-r--r-- | src/us/minak/OnBackspacePressedListener.java | 14 | ||||
-rw-r--r-- | src/us/minak/OnCharacterEnteredListener.java | 13 | ||||
-rw-r--r-- | src/us/minak/SymbolsActivity.java | 42 |
7 files changed, 29 insertions, 210 deletions
diff --git a/src/us/minak/IMEService.java b/src/us/minak/IMEService.java index ba09656..6064be9 100644 --- a/src/us/minak/IMEService.java +++ b/src/us/minak/IMEService.java @@ -18,7 +18,12 @@ public class IMEService extends InputMethodService { public View onCreateInputView() { final IMEView view = (IMEView) getLayoutInflater().inflate(R.layout.ime, null); - // TODO: there probably needs to be more stuff here + view.setOnCharacterEnteredListener(new OnCharacterEnteredListener() { + @Override + public void characterEntered(String character) { + getCurrentInputConnection().commitText(character, 1); + } + }); this.imeView = view; return view; diff --git a/src/us/minak/IMEView.java b/src/us/minak/IMEView.java index 89d6d0a..d341ae5 100644 --- a/src/us/minak/IMEView.java +++ b/src/us/minak/IMEView.java @@ -5,7 +5,30 @@ import android.util.AttributeSet; import android.widget.RelativeLayout; public class IMEView extends RelativeLayout{ + private final Context mContext; + private OnCharacterEnteredListener mOnCharacterEnteredListener; public IMEView(Context context, AttributeSet attrs) { super(context, attrs); + mContext = context; + } + + @Override + protected void onFinishInflate() { + DrawingSpaceView drawingSpaceView = (DrawingSpaceView) findViewById(R.id.drawing_space); + drawingSpaceView.setOnGestureRecognizedListener(new OnGestureRecognizedListener() { + @Override + public void gestureRecognized(String character) { + enterCharacter(character); + } + + }); + } + + public void setOnCharacterEnteredListener(OnCharacterEnteredListener onCharacterEnteredListener) { + mOnCharacterEnteredListener = onCharacterEnteredListener; + } + + private void enterCharacter(String character) { + mOnCharacterEnteredListener.characterEntered(character); } } diff --git a/src/us/minak/Minak.java b/src/us/minak/Minak.java deleted file mode 100644 index e256d9d..0000000 --- a/src/us/minak/Minak.java +++ /dev/null @@ -1,38 +0,0 @@ -package us.minak; - -import android.inputmethodservice.InputMethodService; -import java.util.Queue; -import android.view.View; -import android.view.inputmethod.EditorInfo; - - -public class Minak extends InputMethodService { - private MinakView m_minak_view; - - @Override - public View onCreateInputView() { - final MinakView minak_view = (MinakView) getLayoutInflater().inflate(R.layout.minak, null); - - minak_view.setOnCharacterEnteredListener(new OnCharacterEnteredListener() { - @Override - public void characterEntered(String character) { - getCurrentInputConnection().commitText(character, 1); - } - }); - - - m_minak_view = minak_view; - return minak_view; - } - - @Override - public void onStartInput(EditorInfo attribute, boolean restarting) { - if (m_minak_view != null) { - final Queue<Character> symbolsQueue = m_minak_view.getSymbolsQueue(); - while (!symbolsQueue.isEmpty()) { - final Character character = symbolsQueue.poll(); - getCurrentInputConnection().commitText(String.valueOf(character), 1); - } - } - } -} diff --git a/src/us/minak/MinakView.java b/src/us/minak/MinakView.java deleted file mode 100644 index 3f9373e..0000000 --- a/src/us/minak/MinakView.java +++ /dev/null @@ -1,102 +0,0 @@ -package us.minak; - -import android.content.Context; -import android.widget.Button; -import android.widget.RelativeLayout; -import android.util.AttributeSet; -import android.support.v4.content.LocalBroadcastManager; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.content.BroadcastReceiver; - -import java.util.*; - -public class MinakView extends RelativeLayout { - private final Context mContext; - private OnCharacterEnteredListener mOnCharacterEnteredListener; - - private ShiftState mShiftState = ShiftState.OFF; - private final Queue<Character> mSymbolsQueue = new LinkedList<Character>(); - - private enum ShiftState { - OFF, ON, CAPS_LOCK - }; - - public MinakView(Context context, AttributeSet attrs) { - super(context, attrs); - mContext = context; - LocalBroadcastManager.getInstance(mContext).registerReceiver(mBroadcastReceiver, - new IntentFilter(SymbolsActivity.INTENT_ACTION)); - } - - @Override - protected void onFinishInflate() { - DrawingSpaceView drawingSpaceView = (DrawingSpaceView) findViewById(R.id.drawing_space); - drawingSpaceView.setOnGestureRecognizedListener(new OnGestureRecognizedListener() { - @Override - public void gestureRecognized(String character) { - enterCharacter(character); - } - }); - } - - public void setOnCharacterEnteredListener(OnCharacterEnteredListener onCharacterEnteredListener) { - mOnCharacterEnteredListener = onCharacterEnteredListener; - } - - - - public Queue<Character> getSymbolsQueue() { - return mSymbolsQueue; - } - - /** - * Receiver for broadcasts coming from the symbols activity. - */ - private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - if (SymbolsActivity.INTENT_ACTION.equals(intent.getAction())) { - mSymbolsQueue.add(intent.getCharExtra(SymbolsActivity.INTENT_EXTRA_NAME, '?')); - } - } - }; - - /** - * Listener handling pressing all buttons. - */ - - /** - * Listener handling long pressing all buttons. - */ - - - /** - * Changes shift state to the next one (OFF -> ON -> CAPS LOCK). - */ - - - /** - * Passes the given character to the input service. - * - * @param character - * The character to enter - */ - private void enterCharacter(String character) { - switch (mShiftState) { - case OFF: - mOnCharacterEnteredListener.characterEntered(character); - break; - case ON: - mOnCharacterEnteredListener.characterEntered(character.toUpperCase(Locale.ENGLISH)); - break; - case CAPS_LOCK: - mOnCharacterEnteredListener.characterEntered(character.toUpperCase(Locale.ENGLISH)); - break; - default: - throw new IllegalArgumentException(); - } - } - -}
\ No newline at end of file diff --git a/src/us/minak/OnBackspacePressedListener.java b/src/us/minak/OnBackspacePressedListener.java deleted file mode 100644 index 8e22d13..0000000 --- a/src/us/minak/OnBackspacePressedListener.java +++ /dev/null @@ -1,14 +0,0 @@ -package us.minak; - -/** - * A simple interface for handling pressing the backspace button. - */ -public interface OnBackspacePressedListener { - /** - * Invoked when the backspace button is pressed. - * - * @param isLongClick - * if the button is long pressed - */ - void backspacePressed(boolean isLongClick); -} diff --git a/src/us/minak/OnCharacterEnteredListener.java b/src/us/minak/OnCharacterEnteredListener.java deleted file mode 100644 index feaf451..0000000 --- a/src/us/minak/OnCharacterEnteredListener.java +++ /dev/null @@ -1,13 +0,0 @@ -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/SymbolsActivity.java b/src/us/minak/SymbolsActivity.java deleted file mode 100644 index a295058..0000000 --- a/src/us/minak/SymbolsActivity.java +++ /dev/null @@ -1,42 +0,0 @@ -package us.minak; - - -import android.app.Activity; -import android.content.Intent; -import android.os.Bundle; -import android.support.v4.content.LocalBroadcastManager; -import android.view.View; -import android.view.Window; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemClickListener; -import android.widget.ArrayAdapter; -import android.widget.GridView; - -/** - * Represents the window for choosing additional characters. - */ -public class SymbolsActivity extends Activity { - public static final String INTENT_ACTION = "com.samsung.penboard.SYMBOL_ENTERED"; - public static final String INTENT_EXTRA_NAME = "symbol"; - private static final Character[] SYMBOLS = new Character[] { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '!', - '@', '#', '$', '%', '^', '&', '*', '(', ')', '`', '-', '=', '~', '_', '+', '[', ']', '\\', '{', '}', '|', - ';', '\'', ':', '\'', ',', '.', '/', '<', '>', '?' }; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - requestWindowFeature(Window.FEATURE_NO_TITLE); - final GridView gridView = (GridView) findViewById(R.id.symbols_gridview); - final ArrayAdapter<Character> adapter = new ArrayAdapter<Character>(this, android.R.layout.simple_list_item_1, - SYMBOLS); - gridView.setAdapter(adapter); - gridView.setOnItemClickListener(new OnItemClickListener() { - @Override - public void onItemClick(AdapterView<?> parent, View view, int position, long id) { - final Intent intent = new Intent(INTENT_ACTION); - intent.putExtra(INTENT_EXTRA_NAME, SYMBOLS[position]); - LocalBroadcastManager.getInstance(SymbolsActivity.this).sendBroadcast(intent); - } - }); - } -} |