MainActivity.java 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 getApplicationContext().getExternalFilesDir(null).getAbsolutePath();
  17. //return Environment.getExternalStorageDirectory().getAbsolutePath();
  18. }
  19. public int getKeyboardHeight() {
  20. WindowInsets windowInsets = view.getRootWindowInsets();
  21. if (windowInsets == null) {
  22. return 0;
  23. }
  24. Insets imeInsets = windowInsets.getInsets(WindowInsets.Type.ime());
  25. Insets navInsets = windowInsets.getInsets(WindowInsets.Type.navigationBars());
  26. return Math.max(0, imeInsets.bottom - navInsets.bottom);
  27. }
  28. //% END
  29. //% QUAD_SURFACE_ON_CREATE_INPUT_CONNECTION
  30. // Needed to fix error: unreachable statement in Java
  31. if (true) {
  32. outAttrs.inputType = EditorInfo.TYPE_CLASS_TEXT
  33. | EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT;
  34. outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_FULLSCREEN
  35. | EditorInfo.IME_ACTION_NONE;
  36. return new CustomInputConnection(this, outAttrs);
  37. }
  38. //% END