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() { public void run() {
InputMethodManager imm = InputMethodManager imm =
(InputMethodManager) getContext().getSystemService(INPUT_METHOD_SERVICE); (InputMethodManager) getContext().getSystemService(INPUT_METHOD_SERVICE);
boolean isAcceptingText = false; boolean isAcceptingText = false;
try {
if (imm != null) { if (imm != null) {
try {
// imm.isAcceptingText() seems to sometimes crash on some devices // imm.isAcceptingText() seems to sometimes crash on some devices
isAcceptingText = imm.isAcceptingText(); isAcceptingText = imm.isAcceptingText();
}
} catch (Exception ignored) { } catch (Exception ignored) {
} }
}
if (containerView != null && imm != null && !isAcceptingText) { if (containerView != null && imm != null && !isAcceptingText) {
imm.hideSoftInputFromWindow( imm.hideSoftInputFromWindow(
containerView.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); 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)) ///- MacOS ([Official API - WKWebView.canGoBack](https://developer.apple.com/documentation/webkit/wkwebview/1414966-cangoback))
Future<bool> canGoBack() async { Future<bool> canGoBack() async {
Map<String, dynamic> args = <String, dynamic>{}; 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. ///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)) ///- MacOS ([Official API - WKWebView.canGoForward](https://developer.apple.com/documentation/webkit/wkwebview/1414962-cangoforward))
Future<bool> canGoForward() async { Future<bool> canGoForward() async {
Map<String, dynamic> args = <String, dynamic>{}; 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. ///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.