Advertisement
Guest User

Untitled

a guest
Jun 24th, 2012
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. package com.mykeyboard;
  2.  
  3. import java.util.List;
  4.  
  5. import android.inputmethodservice.InputMethodService;
  6. import android.inputmethodservice.Keyboard.Key;
  7. import android.inputmethodservice.KeyboardView;
  8. import android.view.KeyEvent;
  9. import android.view.View;
  10. import android.view.inputmethod.EditorInfo;
  11. import android.view.inputmethod.InputConnection;
  12.  
  13. public class MyKeyboardService extends InputMethodService implements
  14. KeyboardView.OnKeyboardActionListener {
  15.  
  16. private MyKeyboardView mInputView;
  17. private MyKeyboardFeedbackView mFeedbackView;
  18. private MyKeyboard mKeyboard;
  19.  
  20. @Override
  21. public void onCreate() {
  22. super.onCreate();
  23. mKeyboard = new MyKeyboard(this, R.xml.qwerty);
  24. }
  25.  
  26. @Override
  27. public View onCreateInputView() {
  28. mInputView = (MyKeyboardView) getLayoutInflater().inflate(
  29. R.layout.input, null);
  30. mInputView.setOnKeyboardActionListener(this);
  31. mInputView.setKeyboard(mKeyboard);
  32. mInputView.setPreviewEnabled(false);
  33.  
  34. setCandidatesViewShown(true);
  35. return mInputView;
  36. }
  37.  
  38. @Override
  39. public View onCreateCandidatesView() {
  40. mFeedbackView = new MyKeyboardFeedbackView(this);
  41. return mFeedbackView;
  42. }
  43.  
  44. @Override
  45. public void onStartInput(EditorInfo attribute, boolean restarting) {
  46. super.onStartInput(attribute, restarting);
  47.  
  48. }
  49.  
  50. @Override
  51. public boolean onKeyDown(int keyCode, KeyEvent event) {
  52. return super.onKeyDown(keyCode, event);
  53. }
  54.  
  55. @Override
  56. public boolean onKeyUp(int keyCode, KeyEvent event) {
  57. return super.onKeyUp(keyCode, event);
  58. }
  59.  
  60. @Override
  61. public void onKey(int arg0, int[] arg1) {
  62.  
  63. }
  64.  
  65. @Override
  66. public void onPress(int arg0) {
  67. if (arg0 == 8) {// Backspace
  68. InputConnection ic = getCurrentInputConnection();
  69. ic.deleteSurroundingText(1, 0);
  70. } else {
  71. InputConnection ic = getCurrentInputConnection();
  72. ic.commitText("" + (char) arg0, 0);
  73. }
  74.  
  75. List<Key> l = mInputView.getKeyboard().getKeys();
  76.  
  77. for(int i = 0; i < l.size(); i++)
  78. {
  79. if(l.get(i).codes[0] == 113)
  80. {
  81. // l.get(i).icon = getResources().getDrawable(R.drawable.key);
  82. }
  83. }
  84. }
  85.  
  86. @Override
  87. public void onRelease(int arg0) {
  88.  
  89. }
  90.  
  91. @Override
  92. public void onText(CharSequence arg0) {
  93. // TODO Auto-generated method stub
  94.  
  95. }
  96.  
  97. @Override
  98. public void swipeDown() {
  99. // TODO Auto-generated method stub
  100.  
  101. }
  102.  
  103. @Override
  104. public void swipeLeft() {
  105. // TODO Auto-generated method stub
  106.  
  107. }
  108.  
  109. @Override
  110. public void swipeRight() {
  111. // TODO Auto-generated method stub
  112.  
  113. }
  114.  
  115. @Override
  116. public void swipeUp() {
  117. // TODO Auto-generated method stub
  118.  
  119. }
  120.  
  121. @Override
  122. public void onComputeInsets(InputMethodService.Insets outInsets) {
  123. super.onComputeInsets(outInsets);
  124. if (!isFullscreenMode()) {
  125. outInsets.contentTopInsets = outInsets.visibleTopInsets;
  126. }
  127. }
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement