MainActivity.java 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //% IMPORTS
  2. import android.view.inputmethod.InputMethodManager;
  3. import android.os.Environment;
  4. import autosuggest.CustomInputConnection;
  5. //% END
  6. //% MAIN_ACTIVITY_BODY
  7. public void cancelComposition() {
  8. InputMethodManager imm =
  9. (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
  10. imm.restartInput(view);
  11. }
  12. public String getAppDataPath() {
  13. return getApplicationContext().getDataDir().getAbsolutePath();
  14. }
  15. public String getExternalStoragePath() {
  16. return Environment.getExternalStorageDirectory().getAbsolutePath();
  17. }
  18. public int getKeyboardHeight() {
  19. WindowInsets windowInsets = view.getRootWindowInsets();
  20. if (windowInsets == null) {
  21. return 0;
  22. }
  23. Insets imeInsets = windowInsets.getInsets(WindowInsets.Type.ime());
  24. Insets navInsets = windowInsets.getInsets(WindowInsets.Type.navigationBars());
  25. return Math.max(0, imeInsets.bottom - navInsets.bottom);
  26. }
  27. //% END
  28. //% QUAD_SURFACE_ON_CREATE_INPUT_CONNECTION
  29. // Needed to fix error: unreachable statement in Java
  30. if (true) {
  31. outAttrs.inputType = EditorInfo.TYPE_CLASS_TEXT
  32. | EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT;
  33. outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_FULLSCREEN
  34. | EditorInfo.IME_ACTION_NONE;
  35. return new CustomInputConnection(this, outAttrs);
  36. }
  37. //% END