DebugActivity.java 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package com.uidef.edit;
  2. import android.app.NativeActivity;
  3. import android.os.Bundle;
  4. import android.view.KeyEvent;
  5. import android.view.inputmethod.InputMethodManager;
  6. import android.content.Context;
  7. import java.util.LinkedList;
  8. import java.util.Queue;
  9. public class DebugActivity extends NativeActivity {
  10. private Queue<Integer> mQueuedUnicodeChars = new LinkedList<>();
  11. static {
  12. System.loadLibrary("uidef-tool");
  13. }
  14. @Override
  15. protected void onCreate(Bundle savedInstanceState) {
  16. super.onCreate(savedInstanceState);
  17. }
  18. @Override
  19. public boolean dispatchKeyEvent(KeyEvent event) {
  20. if (event.getAction() == KeyEvent.ACTION_DOWN) {
  21. int unicodeChar = event.getUnicodeChar();
  22. if (unicodeChar != 0)
  23. mQueuedUnicodeChars.add(unicodeChar);
  24. }
  25. return super.dispatchKeyEvent(event);
  26. }
  27. public void showSoftInput() {
  28. InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
  29. imm.showSoftInput(getWindow().getDecorView(), 0);
  30. }
  31. public int pollUnicodeChar() {
  32. Integer c = mQueuedUnicodeChars.poll();
  33. return c != null ? c : 0;
  34. }
  35. public native String nativeDiagnostic(String dataDir);
  36. }