From d12afb24b9d2048fe2cb08451e03240c43ac08fb Mon Sep 17 00:00:00 2001 From: DavisLWebb Date: Sun, 4 May 2014 20:38:47 -0400 Subject: asdjfa --- src/us/minak/Minak.java | 28 ------------- src/us/minak/MinakView.java | 84 ++------------------------------------- src/us/minak/SymbolsActivity.java | 1 - 3 files changed, 3 insertions(+), 110 deletions(-) diff --git a/src/us/minak/Minak.java b/src/us/minak/Minak.java index af2736f..e256d9d 100644 --- a/src/us/minak/Minak.java +++ b/src/us/minak/Minak.java @@ -20,16 +20,6 @@ public class Minak extends InputMethodService { } }); - minak_view.setOnBackspacePressedListener(new OnBackspacePressedListener() { - @Override - public void backspacePressed(boolean isLongClick) { - if (isLongClick) { - deleteLastWord(); - } else { - getCurrentInputConnection().deleteSurroundingText(1, 0); - } - } - }); m_minak_view = minak_view; return minak_view; @@ -45,22 +35,4 @@ public class Minak 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/MinakView.java b/src/us/minak/MinakView.java index fe8cd25..3f9373e 100644 --- a/src/us/minak/MinakView.java +++ b/src/us/minak/MinakView.java @@ -15,8 +15,7 @@ import java.util.*; public class MinakView extends RelativeLayout { private final Context mContext; private OnCharacterEnteredListener mOnCharacterEnteredListener; - private OnBackspacePressedListener mOnBackspacePressedListener; - private Button mShiftButton; + private ShiftState mShiftState = ShiftState.OFF; private final Queue mSymbolsQueue = new LinkedList(); @@ -40,31 +39,13 @@ public class MinakView extends RelativeLayout { enterCharacter(character); } }); - - final Button symbolsButton = (Button) findViewById(R.id.symbols_btn); - symbolsButton.setOnClickListener(mButtonClickListener); - symbolsButton.setOnLongClickListener(mButtonLongClickListener); - - 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(OnCharacterEnteredListener onCharacterEnteredListener) { mOnCharacterEnteredListener = onCharacterEnteredListener; } - public void setOnBackspacePressedListener(OnBackspacePressedListener onBackspacePressedListener) { - mOnBackspacePressedListener = onBackspacePressedListener; - } + public Queue getSymbolsQueue() { return mSymbolsQueue; @@ -85,74 +66,16 @@ public class MinakView extends RelativeLayout { /** * Listener handling pressing all buttons. */ - private final OnClickListener mButtonClickListener = new OnClickListener() { - @Override - public void onClick(View v) { - switch (v.getId()) { - case R.id.symbols_btn: - final Intent intent = new Intent(mContext, SymbolsActivity.class); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - mContext.startActivity(intent); - break; - case R.id.shift_btn: - shift(); - break; - case R.id.backspace_btn: - mOnBackspacePressedListener.backspacePressed(false); - break; - case R.id.space_btn: - mOnCharacterEnteredListener.characterEntered(" "); - 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.symbols_btn: - 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. @@ -167,7 +90,6 @@ public class MinakView extends RelativeLayout { break; case ON: mOnCharacterEnteredListener.characterEntered(character.toUpperCase(Locale.ENGLISH)); - shift(); break; case CAPS_LOCK: mOnCharacterEnteredListener.characterEntered(character.toUpperCase(Locale.ENGLISH)); diff --git a/src/us/minak/SymbolsActivity.java b/src/us/minak/SymbolsActivity.java index 3480fa4..a295058 100644 --- a/src/us/minak/SymbolsActivity.java +++ b/src/us/minak/SymbolsActivity.java @@ -26,7 +26,6 @@ public class SymbolsActivity extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); - setContentView(R.layout.symbols); final GridView gridView = (GridView) findViewById(R.id.symbols_gridview); final ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, SYMBOLS); -- cgit v1.2.3-54-g00ecf