slint/internal/backends/android-activity/java/SlintAndroidJavaHelper.java
Olivier Goffart daa40f43cd 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
2024-01-21 09:21:41 +01:00

24 lines
925 B
Java

// 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);
}
}