Android: Use java code to show or hide the keyboard

instead of coding it all in JNI

This uses build.rs to compile the java code into bytecode that is then
embedded in the binary and loaded at runtime
This commit is contained in:
Olivier Goffart 2024-01-12 13:25:48 +01:00
parent a46b70833a
commit daa40f43cd
4 changed files with 178 additions and 38 deletions

View file

@ -0,0 +1,24 @@
// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial
import android.view.View;
import android.content.Context;
import android.view.inputmethod.InputMethodManager;
import android.app.Activity;
public class SlintAndroidJavaHelper {
Activity mActivity;
public SlintAndroidJavaHelper(Activity activity) {
this.mActivity = activity;
}
public void show_keyboard() {
InputMethodManager imm = (InputMethodManager)mActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(mActivity.getWindow().getDecorView(), 0);
}
public void hide_keyboard() {
InputMethodManager imm = (InputMethodManager)mActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mActivity.getWindow().getDecorView().getWindowToken(), 0);
}
}