federicoiosue / Omni-Notes

Open source note-taking application for Android
https://omninotes.app
GNU General Public License v3.0
2.68k stars 1.11k forks source link

Compatibility issue when calling method #864

Closed PSDroid2022 closed 1 year ago

PSDroid2022 commented 1 year ago

We confirm a compatibility issue which might threaten the robustness of your app and give a detailed suggestion for you.

In ''it.feio.android.omninotes.utils.KeyboardUtils", you invoke the API "<android.view.inputmethod.InputMethodManager: void toggleSoftInput(int,int)>" in "showKeyboard" method as shown in following. But actually, this API is deprecated in API level 31( https://developer.android.google.cn/reference/android/view/inputmethod/InputMethodManager?hl=en#toggleSoftInput(int,%20int)).

 @Override
 public static void showKeyboard(View view) {
    if (view == null) {
      return;
    }

    view.requestFocus();

    InputMethodManager inputManager = (InputMethodManager) view.getContext().getSystemService(
        Context.INPUT_METHOD_SERVICE);
    inputManager.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);

    ((InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE))
        .showSoftInput(view, 0);

    if (!isKeyboardShowed(view)) {
      inputManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
    }
  }

So when the app try to invoke this API on devices after API level 31, your app will run with an unpredictable results. So we suggest you add an "if(SDK_INT < 31)" to fix this potential issue.

Android device

federicoiosue commented 1 year ago

Hi there, thanks for the info. I'll currently tag this as wontfix for now because:

But I'll keep in mind the necessity to change this part when upgrading further.