android imm.isAcceptingText() fix code refactoring

This commit is contained in:
Lorenzo Pichilli 2023-11-10 21:12:14 +01:00
parent fb7e025ee0
commit adcfdce7ed
2 changed files with 14 additions and 12 deletions

View File

@ -1525,14 +1525,16 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
public void run() {
InputMethodManager imm =
(InputMethodManager) getContext().getSystemService(INPUT_METHOD_SERVICE);
boolean isAcceptingText = false;
try {
if (imm != null) {
if (imm != null) {
try {
// imm.isAcceptingText() seems to sometimes crash on some devices
isAcceptingText = imm.isAcceptingText();
} catch (Exception ignored) {
}
} catch (Exception ignored) {
}
if (containerView != null && imm != null && !isAcceptingText) {
imm.hideSoftInputFromWindow(
containerView.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);

View File

@ -1878,7 +1878,7 @@ class InAppWebViewController {
///- MacOS ([Official API - WKWebView.canGoBack](https://developer.apple.com/documentation/webkit/wkwebview/1414966-cangoback))
Future<bool> canGoBack() async {
Map<String, dynamic> args = <String, dynamic>{};
return await _channel?.invokeMethod<bool>('canGoBack', args) ?? false;
return await _channel?.invokeMethod('canGoBack', args);
}
///Goes forward in the history of the WebView.
@ -1903,7 +1903,7 @@ class InAppWebViewController {
///- MacOS ([Official API - WKWebView.canGoForward](https://developer.apple.com/documentation/webkit/wkwebview/1414962-cangoforward))
Future<bool> canGoForward() async {
Map<String, dynamic> args = <String, dynamic>{};
return await _channel?.invokeMethod('canGoForward', args) ?? false;
return await _channel?.invokeMethod('canGoForward', args);
}
///Goes to the history item that is the number of steps away from the current item. Steps is negative if backward and positive if forward.