parent
83dae97fda
commit
2eb31ee74f
|
@ -21,6 +21,8 @@
|
|||
- Fixed "Unexpected behavior when using a null initialUrlRequest" [#1063](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1063)
|
||||
- Fixed "Local storage & cookie didn't persist when sharedCookie and cache both enabled" [#1092](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1092)
|
||||
- Fixed "ios zoomBy crash: Foundation/NSNumber.swift:467: Fatal error: Unable to bridge NSNumber to Float" [#873](https://github.com/pichillilorenzo/flutter_inappwebview/issues/873)
|
||||
- Fixed "In App Browser Crashing in Android - Action Bar is null" [#1137](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1137)
|
||||
- Fixed "Cannot load Javascript on some Android devices - Uncaught TypeError: Cannot read property 'appendChild' of null" [#888](https://github.com/pichillilorenzo/flutter_inappwebview/issues/888)
|
||||
- Merged "Update Options.swift" [#889](https://github.com/pichillilorenzo/flutter_inappwebview/pull/889) (thanks to [cloudygeek](https://github.com/cloudygeek))
|
||||
- Merged "fix: Applicatio nNameForUserAgent is not working in iOS" [#1095](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1095) (thanks to [sunalwaysknows](https://github.com/sunalwaysknows))
|
||||
- Merged "Make sure we open a new instance of a custom chrome chrome tab" [#812](https://github.com/pichillilorenzo/flutter_inappwebview/pull/812) (thanks to [savy-91](https://github.com/savy-91))
|
||||
|
|
|
@ -20,6 +20,7 @@ import android.webkit.WebViewClient;
|
|||
import android.widget.ProgressBar;
|
||||
import android.widget.SearchView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
|
@ -50,6 +51,7 @@ public class InAppBrowserActivity extends AppCompatActivity implements InAppBrow
|
|||
public String id;
|
||||
public InAppWebView webView;
|
||||
public PullToRefreshLayout pullToRefreshLayout;
|
||||
@Nullable
|
||||
public ActionBar actionBar;
|
||||
public Menu menu;
|
||||
public SearchView searchView;
|
||||
|
@ -179,17 +181,18 @@ public class InAppBrowserActivity extends AppCompatActivity implements InAppBrow
|
|||
else
|
||||
progressBar.setMax(100);
|
||||
|
||||
actionBar.setDisplayShowTitleEnabled(!options.hideTitleBar);
|
||||
if (actionBar != null) {
|
||||
actionBar.setDisplayShowTitleEnabled(!options.hideTitleBar);
|
||||
|
||||
if (options.hideToolbarTop)
|
||||
actionBar.hide();
|
||||
if (options.hideToolbarTop)
|
||||
actionBar.hide();
|
||||
|
||||
if (options.toolbarTopBackgroundColor != null && !options.toolbarTopBackgroundColor.isEmpty())
|
||||
actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor(options.toolbarTopBackgroundColor)));
|
||||
|
||||
if (options.toolbarTopFixedTitle != null && !options.toolbarTopFixedTitle.isEmpty())
|
||||
actionBar.setTitle(options.toolbarTopFixedTitle);
|
||||
if (options.toolbarTopBackgroundColor != null && !options.toolbarTopBackgroundColor.isEmpty())
|
||||
actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor(options.toolbarTopBackgroundColor)));
|
||||
|
||||
if (options.toolbarTopFixedTitle != null && !options.toolbarTopFixedTitle.isEmpty())
|
||||
actionBar.setTitle(options.toolbarTopFixedTitle);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -208,7 +211,7 @@ public class InAppBrowserActivity extends AppCompatActivity implements InAppBrow
|
|||
|
||||
searchView.setQuery(webView.getUrl(), false);
|
||||
|
||||
if (options.toolbarTopFixedTitle == null || options.toolbarTopFixedTitle.isEmpty())
|
||||
if (actionBar != null && (options.toolbarTopFixedTitle == null || options.toolbarTopFixedTitle.isEmpty()))
|
||||
actionBar.setTitle(webView.getTitle());
|
||||
|
||||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
|
@ -372,21 +375,24 @@ public class InAppBrowserActivity extends AppCompatActivity implements InAppBrow
|
|||
progressBar.setMax(100);
|
||||
}
|
||||
|
||||
if (newOptionsMap.get("hideTitleBar") != null && options.hideTitleBar != newOptions.hideTitleBar)
|
||||
if (actionBar != null && newOptionsMap.get("hideTitleBar") != null && options.hideTitleBar != newOptions.hideTitleBar)
|
||||
actionBar.setDisplayShowTitleEnabled(!newOptions.hideTitleBar);
|
||||
|
||||
if (newOptionsMap.get("hideToolbarTop") != null && options.hideToolbarTop != newOptions.hideToolbarTop) {
|
||||
if (actionBar != null && newOptionsMap.get("hideToolbarTop") != null && options.hideToolbarTop != newOptions.hideToolbarTop) {
|
||||
if (newOptions.hideToolbarTop)
|
||||
actionBar.hide();
|
||||
else
|
||||
actionBar.show();
|
||||
}
|
||||
|
||||
if (newOptionsMap.get("toolbarTopBackgroundColor") != null && !Util.objEquals(options.toolbarTopBackgroundColor, newOptions.toolbarTopBackgroundColor) &&
|
||||
if (actionBar != null && newOptionsMap.get("toolbarTopBackgroundColor") != null &&
|
||||
!Util.objEquals(options.toolbarTopBackgroundColor, newOptions.toolbarTopBackgroundColor) &&
|
||||
!newOptions.toolbarTopBackgroundColor.isEmpty())
|
||||
actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor(newOptions.toolbarTopBackgroundColor)));
|
||||
|
||||
if (newOptionsMap.get("toolbarTopFixedTitle") != null && !Util.objEquals(options.toolbarTopFixedTitle, newOptions.toolbarTopFixedTitle) && !newOptions.toolbarTopFixedTitle.isEmpty())
|
||||
if (actionBar != null && newOptionsMap.get("toolbarTopFixedTitle") != null &&
|
||||
!Util.objEquals(options.toolbarTopFixedTitle, newOptions.toolbarTopFixedTitle) &&
|
||||
!newOptions.toolbarTopFixedTitle.isEmpty())
|
||||
actionBar.setTitle(newOptions.toolbarTopFixedTitle);
|
||||
|
||||
if (newOptionsMap.get("hideUrlBar") != null && options.hideUrlBar != newOptions.hideUrlBar) {
|
||||
|
|
|
@ -1064,12 +1064,13 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
|
|||
}
|
||||
}
|
||||
String jsWrapper = "(function(d) { var script = d.createElement('script'); " + scriptAttributes +
|
||||
" script.src = %s; d.body.appendChild(script); })(document);";
|
||||
" script.src = %s; if (d.body != null) { d.body.appendChild(script); } })(document);";
|
||||
injectDeferredObject(urlFile, null, jsWrapper, null);
|
||||
}
|
||||
|
||||
public void injectCSSCode(String source) {
|
||||
String jsWrapper = "(function(d) { var style = d.createElement('style'); style.innerHTML = %s; d.head.appendChild(style); })(document);";
|
||||
String jsWrapper = "(function(d) { var style = d.createElement('style'); style.innerHTML = %s;" +
|
||||
" if (d.head != null) { d.head.appendChild(style); } })(document);";
|
||||
injectDeferredObject(source, null, jsWrapper, null);
|
||||
}
|
||||
|
||||
|
@ -1111,7 +1112,7 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
|
|||
}
|
||||
}
|
||||
String jsWrapper = "(function(d) { var link = d.createElement('link'); link.rel='" + alternateStylesheet + "stylesheet'; link.type='text/css'; " +
|
||||
cssLinkAttributes + " link.href = %s; d.head.appendChild(link); })(document);";
|
||||
cssLinkAttributes + " link.href = %s; if (d.head != null) { d.head.appendChild(link); } })(document);";
|
||||
injectDeferredObject(urlFile, null, jsWrapper, null);
|
||||
}
|
||||
|
||||
|
|
|
@ -70,3 +70,5 @@ build/
|
|||
!**/ios/**/default.pbxuser
|
||||
!**/ios/**/default.perspectivev3
|
||||
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
|
||||
|
||||
integration_test/.env.dart
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
final environment = {"NODE_SERVER_IP":"192.168.1.123"};
|
|
@ -5737,6 +5737,84 @@ setTimeout(function() {
|
|||
await chromeSafariBrowser.browserClosed.future;
|
||||
expect(chromeSafariBrowser.isOpened(), false);
|
||||
});
|
||||
|
||||
group('Android Custom Tabs', () {
|
||||
test('Custom Tabs single instance', () async {
|
||||
var chromeSafariBrowser = new MyChromeSafariBrowser();
|
||||
expect(chromeSafariBrowser.isOpened(), false);
|
||||
|
||||
await chromeSafariBrowser.open(
|
||||
url: Uri.parse("https://github.com/flutter"),
|
||||
options: ChromeSafariBrowserClassOptions(
|
||||
android: AndroidChromeCustomTabsOptions(
|
||||
isSingleInstance: true
|
||||
)
|
||||
)
|
||||
);
|
||||
await chromeSafariBrowser.browserCreated.future;
|
||||
expect(chromeSafariBrowser.isOpened(), true);
|
||||
expect(() async {
|
||||
await chromeSafariBrowser.open(
|
||||
url: Uri.parse("https://flutter.dev"));
|
||||
}, throwsA(isInstanceOf<ChromeSafariBrowserAlreadyOpenedException>()));
|
||||
|
||||
await expectLater(chromeSafariBrowser.firstPageLoaded.future, completes);
|
||||
await chromeSafariBrowser.close();
|
||||
await chromeSafariBrowser.browserClosed.future;
|
||||
expect(chromeSafariBrowser.isOpened(), false);
|
||||
});
|
||||
|
||||
test('Trusted Web Activity', () async {
|
||||
var chromeSafariBrowser = new MyChromeSafariBrowser();
|
||||
expect(chromeSafariBrowser.isOpened(), false);
|
||||
|
||||
await chromeSafariBrowser.open(
|
||||
url: Uri.parse("https://github.com/flutter"),
|
||||
options: ChromeSafariBrowserClassOptions(
|
||||
android: AndroidChromeCustomTabsOptions(
|
||||
isTrustedWebActivity: true
|
||||
)
|
||||
)
|
||||
);
|
||||
await chromeSafariBrowser.browserCreated.future;
|
||||
expect(chromeSafariBrowser.isOpened(), true);
|
||||
expect(() async {
|
||||
await chromeSafariBrowser.open(
|
||||
url: Uri.parse("https://flutter.dev"));
|
||||
}, throwsA(isInstanceOf<ChromeSafariBrowserAlreadyOpenedException>()));
|
||||
|
||||
await expectLater(chromeSafariBrowser.firstPageLoaded.future, completes);
|
||||
await chromeSafariBrowser.close();
|
||||
await chromeSafariBrowser.browserClosed.future;
|
||||
expect(chromeSafariBrowser.isOpened(), false);
|
||||
});
|
||||
|
||||
test('Trusted Web Activity single instance', () async {
|
||||
var chromeSafariBrowser = new MyChromeSafariBrowser();
|
||||
expect(chromeSafariBrowser.isOpened(), false);
|
||||
|
||||
await chromeSafariBrowser.open(
|
||||
url: Uri.parse("https://github.com/flutter"),
|
||||
options: ChromeSafariBrowserClassOptions(
|
||||
android: AndroidChromeCustomTabsOptions(
|
||||
isTrustedWebActivity: true,
|
||||
isSingleInstance: true
|
||||
)
|
||||
)
|
||||
);
|
||||
await chromeSafariBrowser.browserCreated.future;
|
||||
expect(chromeSafariBrowser.isOpened(), true);
|
||||
expect(() async {
|
||||
await chromeSafariBrowser.open(
|
||||
url: Uri.parse("https://flutter.dev"));
|
||||
}, throwsA(isInstanceOf<ChromeSafariBrowserAlreadyOpenedException>()));
|
||||
|
||||
await expectLater(chromeSafariBrowser.firstPageLoaded.future, completes);
|
||||
await chromeSafariBrowser.close();
|
||||
await chromeSafariBrowser.browserClosed.future;
|
||||
expect(chromeSafariBrowser.isOpened(), false);
|
||||
});
|
||||
}, skip: !Platform.isAndroid);
|
||||
});
|
||||
|
||||
group('InAppLocalhostServer', () {
|
||||
|
|
|
@ -14,7 +14,7 @@ dependencies:
|
|||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
pedantic: ^1.10.0-nullsafety.1
|
||||
pedantic: ^1.11.1
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://www.dartlang.org/tools/pub/pubspec
|
||||
|
|
Loading…
Reference in New Issue