MainActivity.java 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. Insets insets = view.getRootWindowInsets().getInsets(WindowInsets.Type.ime());
  20. return insets.bottom;
  21. }
  22. //% END
  23. //% QUAD_SURFACE_ON_CREATE_INPUT_CONNECTION
  24. // Needed to fix error: unreachable statement in Java
  25. if (true) {
  26. outAttrs.inputType = EditorInfo.TYPE_CLASS_TEXT
  27. | EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT;
  28. outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_FULLSCREEN
  29. | EditorInfo.IME_ACTION_NONE;
  30. return new CustomInputConnection(this, outAttrs);
  31. }
  32. //% END