This commit is contained in:
Lorenzo Pichilli 2022-05-05 21:55:31 +02:00
parent 88e89bd102
commit b53703401e
2 changed files with 58 additions and 41 deletions

View File

@ -17,6 +17,15 @@
- On Android, the `InAppWebView` widget uses hybrid composition by default (`useHybridComposition: true`). - On Android, the `InAppWebView` widget uses hybrid composition by default (`useHybridComposition: true`).
- All properties of `GeolocationPermissionShowPromptResponse` cannot be `null`; - All properties of `GeolocationPermissionShowPromptResponse` cannot be `null`;
## 5.4.3+6
- Fixed "iOS flutter_inappwebview/URLRequest.swift:13: Fatal error: Unexpectedly found nil while unwrapping an Optional value" [#1173](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1173)
## 5.4.3+5
- Fixed possible java.lang.NullPointerException in `Runnable` of `InputAwareWebView.setInputConnectionTarget` method
- Fixed "Android Crash in latest 5.4.3+4 - java.lang.NullPointerException: Attempt to invoke virtual method java.lang.String android.webkit.WebView.getUrl()" [#1168](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1168)
## 5.4.3+4 ## 5.4.3+4
- Updated docs for `ChromeSafariBrowser.open` and throw error on iOS if the `url` parameter use a different scheme then `http` or `https` - Updated docs for `ChromeSafariBrowser.open` and throw error on iOS if the `url` parameter use a different scheme then `http` or `https`

View File

@ -219,11 +219,14 @@ public class InAppBrowserActivity extends AppCompatActivity implements InAppBrow
// Inflate menu to add items to action bar if it is present. // Inflate menu to add items to action bar if it is present.
inflater.inflate(R.menu.menu_main, menu); inflater.inflate(R.menu.menu_main, menu);
searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView(); MenuItem menuItem = menu.findItem(R.id.menu_search);
searchView.setFocusable(true); if (menuItem != null) {
if (customSettings.hideUrlBar) if (customSettings.hideUrlBar)
menu.findItem(R.id.menu_search).setVisible(false); menuItem.setVisible(false);
searchView = (SearchView) menuItem.getActionView();
if (searchView != null) {
searchView.setFocusable(true);
searchView.setQuery(webView != null ? webView.getUrl() : "", false); searchView.setQuery(webView != null ? webView.getUrl() : "", false);
@ -231,9 +234,12 @@ public class InAppBrowserActivity extends AppCompatActivity implements InAppBrow
@Override @Override
public boolean onQueryTextSubmit(String query) { public boolean onQueryTextSubmit(String query) {
if (!query.isEmpty()) { if (!query.isEmpty()) {
if (webView != null)
webView.loadUrl(query); webView.loadUrl(query);
if (searchView != null) {
searchView.setQuery("", false); searchView.setQuery("", false);
searchView.setIconified(true); searchView.setIconified(true);
}
return true; return true;
} }
return false; return false;
@ -249,8 +255,8 @@ public class InAppBrowserActivity extends AppCompatActivity implements InAppBrow
searchView.setOnCloseListener(new SearchView.OnCloseListener() { searchView.setOnCloseListener(new SearchView.OnCloseListener() {
@Override @Override
public boolean onClose() { public boolean onClose() {
if (searchView.getQuery().toString().isEmpty()) if (searchView != null && searchView.getQuery().toString().isEmpty())
searchView.setQuery(webView.getUrl(), false); searchView.setQuery(webView != null ? webView.getUrl() : "", false);
return false; return false;
} }
}); });
@ -258,12 +264,14 @@ public class InAppBrowserActivity extends AppCompatActivity implements InAppBrow
searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() { searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
@Override @Override
public void onFocusChange(View view, boolean b) { public void onFocusChange(View view, boolean b) {
if (!b) { if (!b && searchView != null) {
searchView.setQuery("", false); searchView.setQuery("", false);
searchView.setIconified(true); searchView.setIconified(true);
} }
} }
}); });
}
}
return true; return true;
} }