This commit is contained in:
Lorenzo Pichilli 2023-12-06 12:35:48 +01:00
parent 7bb70eb7d9
commit 3a9bee5af8
12 changed files with 148 additions and 20 deletions

View File

@ -1,3 +1,8 @@
## 1.0.6
- Fixed "getFavicons: _TypeError: type '_Map<String, dynamic>' is not a subtype of type 'Iterable<dynamic>'" [#1897](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1897)
- Fixed "onClosed not considering back navigation or up button / close button in ChromeSafariBrowser when using noHistory: true" [#1882](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1882)
## 1.0.5
- Call `super.dispose();` on `InAppBrowser` and `ChromeSafari` implementations

View File

@ -8,6 +8,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.pichillilorenzo.flutter_inappwebview_android.chrome_custom_tabs.ChromeSafariBrowserManager;
import com.pichillilorenzo.flutter_inappwebview_android.chrome_custom_tabs.NoHistoryCustomTabsActivityCallbacks;
import com.pichillilorenzo.flutter_inappwebview_android.credential_database.CredentialDatabaseHandler;
import com.pichillilorenzo.flutter_inappwebview_android.headless_in_app_webview.HeadlessInAppWebViewManager;
import com.pichillilorenzo.flutter_inappwebview_android.in_app_browser.InAppBrowserManager;
@ -40,6 +41,8 @@ public class InAppWebViewFlutterPlugin implements FlutterPlugin, ActivityAware {
@Nullable
public ChromeSafariBrowserManager chromeSafariBrowserManager;
@Nullable
public NoHistoryCustomTabsActivityCallbacks noHistoryCustomTabsActivityCallbacks;
@Nullable
public InAppWebViewManager inAppWebViewManager;
@Nullable
public MyCookieManager myCookieManager;
@ -103,6 +106,7 @@ public class InAppWebViewFlutterPlugin implements FlutterPlugin, ActivityAware {
inAppBrowserManager = new InAppBrowserManager(this);
headlessInAppWebViewManager = new HeadlessInAppWebViewManager(this);
chromeSafariBrowserManager = new ChromeSafariBrowserManager(this);
noHistoryCustomTabsActivityCallbacks = new NoHistoryCustomTabsActivityCallbacks(this);
flutterWebViewFactory = new FlutterWebViewFactory(this);
platformViewRegistry.registerViewFactory(
FlutterWebViewFactory.VIEW_TYPE_ID, flutterWebViewFactory);
@ -144,6 +148,10 @@ public class InAppWebViewFlutterPlugin implements FlutterPlugin, ActivityAware {
chromeSafariBrowserManager.dispose();
chromeSafariBrowserManager = null;
}
if (noHistoryCustomTabsActivityCallbacks != null) {
noHistoryCustomTabsActivityCallbacks.dispose();
noHistoryCustomTabsActivityCallbacks = null;
}
if (myCookieManager != null) {
myCookieManager.dispose();
myCookieManager = null;
@ -190,23 +198,39 @@ public class InAppWebViewFlutterPlugin implements FlutterPlugin, ActivityAware {
public void onAttachedToActivity(ActivityPluginBinding activityPluginBinding) {
this.activityPluginBinding = activityPluginBinding;
this.activity = activityPluginBinding.getActivity();
if (noHistoryCustomTabsActivityCallbacks != null) {
this.activity.getApplication().registerActivityLifecycleCallbacks(noHistoryCustomTabsActivityCallbacks.activityLifecycleCallbacks);
}
}
@Override
public void onDetachedFromActivityForConfigChanges() {
this.activityPluginBinding = null;
this.activity = null;
if (activity != null && noHistoryCustomTabsActivityCallbacks != null) {
this.activity.getApplication().unregisterActivityLifecycleCallbacks(noHistoryCustomTabsActivityCallbacks.activityLifecycleCallbacks);
}
activityPluginBinding = null;
activity = null;
}
@Override
public void onReattachedToActivityForConfigChanges(ActivityPluginBinding activityPluginBinding) {
this.activityPluginBinding = activityPluginBinding;
this.activity = activityPluginBinding.getActivity();
if (noHistoryCustomTabsActivityCallbacks != null) {
this.activity.getApplication().registerActivityLifecycleCallbacks(noHistoryCustomTabsActivityCallbacks.activityLifecycleCallbacks);
}
}
@Override
public void onDetachedFromActivity() {
this.activityPluginBinding = null;
this.activity = null;
if (activity != null && noHistoryCustomTabsActivityCallbacks != null) {
this.activity.getApplication().unregisterActivityLifecycleCallbacks(noHistoryCustomTabsActivityCallbacks.activityLifecycleCallbacks);
}
activityPluginBinding = null;
activity = null;
}
}

View File

@ -47,7 +47,8 @@ public class ChromeCustomTabsActivity extends Activity implements Disposable {
public CustomTabActivityHelper customTabActivityHelper = new CustomTabActivityHelper();
@Nullable
public CustomTabsSession customTabsSession;
protected final int CHROME_CUSTOM_TAB_REQUEST_CODE = 100;
public final static int CHROME_CUSTOM_TAB_REQUEST_CODE = 100;
public final static int NO_HISTORY_CHROME_CUSTOM_TAB_REQUEST_CODE = 101;
protected boolean onOpened = false;
protected boolean onCompletedInitialLoad = false;
protected boolean isBindSuccess = false;
@ -104,6 +105,10 @@ public class ChromeCustomTabsActivity extends Activity implements Disposable {
menuItems.add(CustomTabsMenuItem.fromMap(menuItem));
}
if (customSettings.noHistory && manager.plugin.noHistoryCustomTabsActivityCallbacks != null) {
manager.plugin.noHistoryCustomTabsActivityCallbacks.noHistoryBrowserIDs.put(id, id);
}
final ChromeCustomTabsActivity chromeCustomTabsActivity = this;
customTabActivityHelper.setConnectionCallback(new CustomTabActivityHelper.ConnectionCallback() {

View File

@ -0,0 +1,77 @@
package com.pichillilorenzo.flutter_inappwebview_android.chrome_custom_tabs;
import android.app.Activity;
import android.app.Application;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.pichillilorenzo.flutter_inappwebview_android.InAppWebViewFlutterPlugin;
import com.pichillilorenzo.flutter_inappwebview_android.types.Disposable;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import io.flutter.embedding.android.FlutterActivity;
public class NoHistoryCustomTabsActivityCallbacks implements Disposable {
@Nullable
public InAppWebViewFlutterPlugin plugin;
public final Map<String, String> noHistoryBrowserIDs = new HashMap<>();
public NoHistoryCustomTabsActivityCallbacks(@NonNull final InAppWebViewFlutterPlugin plugin) {
this.plugin = plugin;
}
public Application.ActivityLifecycleCallbacks activityLifecycleCallbacks = new Application.ActivityLifecycleCallbacks() {
@Override
public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {
}
@Override
public void onActivityStarted(@NonNull Activity activity) {
}
@Override
public void onActivityResumed(@NonNull Activity activity) {
if (activity instanceof FlutterActivity && plugin != null && plugin.chromeSafariBrowserManager != null) {
Collection<String> browserIds = noHistoryBrowserIDs.values();
for (String browserId : browserIds) {
if (browserId != null) {
noHistoryBrowserIDs.put(browserId, null);
ChromeCustomTabsActivity browser = plugin.chromeSafariBrowserManager.browsers.get(browserId);
if (browser != null) {
browser.close();
browser.dispose();
}
}
}
}
}
@Override
public void onActivityPaused(@NonNull Activity activity) {
}
@Override
public void onActivityStopped(@NonNull Activity activity) {
}
@Override
public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle outState) {
}
@Override
public void onActivityDestroyed(@NonNull Activity activity) {
}
};
@Override
public void dispose() {
noHistoryBrowserIDs.clear();
plugin = null;
}
}

View File

@ -1712,7 +1712,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController
manifestResponse.headers.contentType?.mimeType == "application/json";
} catch (e) {
developer.log("Manifest file not found: " + e.toString(),
name: this.runtimeType.toString());
name: runtimeType.toString());
}
if (manifestFound) {
@ -1725,9 +1725,12 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController
icon["src"], icon["rel"], icon["sizes"], true));
}
}
} on FormatException catch (_) {
/// The [manifestResponse] might not has a valid JSON string, catch and
/// ignore the error
} catch (e) {
developer.log(
"Cannot get favicons from Manifest file. It might not have a valid format: " +
e.toString(),
error: e,
name: runtimeType.toString());
}
}

View File

@ -1,6 +1,6 @@
name: flutter_inappwebview_android
description: Android implementation of the flutter_inappwebview plugin.
version: 1.0.5
version: 1.0.6
homepage: https://inappwebview.dev/
repository: https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_android
issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues

View File

@ -1,3 +1,7 @@
## 1.0.7
- Fixed "getFavicons: _TypeError: type '_Map<String, dynamic>' is not a subtype of type 'Iterable<dynamic>'" [#1897](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1897)
## 1.0.6
- Possible fix for "iOS Fatal Crash" [#1894](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1894)

View File

@ -1689,7 +1689,7 @@ class IOSInAppWebViewController extends PlatformInAppWebViewController
}
} catch (e) {
developer.log("/favicon.ico file not found: " + e.toString(),
name: this.runtimeType.toString());
name: runtimeType.toString());
}
// try to get the manifest file
@ -1721,9 +1721,12 @@ class IOSInAppWebViewController extends PlatformInAppWebViewController
icon["src"], icon["rel"], icon["sizes"], true));
}
}
} on FormatException catch (_) {
/// The [manifestResponse] might not has a valid JSON string, catch and
/// ignore the error
} catch (e) {
developer.log(
"Cannot get favicons from Manifest file. It might not have a valid format: " +
e.toString(),
error: e,
name: runtimeType.toString());
}
}

View File

@ -1,6 +1,6 @@
name: flutter_inappwebview_ios
description: iOS implementation of the flutter_inappwebview plugin.
version: 1.0.6
version: 1.0.7
homepage: https://inappwebview.dev/
repository: https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_ios
issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues

View File

@ -1,3 +1,7 @@
## 1.0.5
- Fixed "getFavicons: _TypeError: type '_Map<String, dynamic>' is not a subtype of type 'Iterable<dynamic>'" [#1897](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1897)
## 1.0.4
- Possible fix for "iOS Fatal Crash" [#1894](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1894)

View File

@ -1690,7 +1690,7 @@ class MacOSInAppWebViewController extends PlatformInAppWebViewController
}
} catch (e) {
developer.log("/favicon.ico file not found: " + e.toString(),
name: this.runtimeType.toString());
name: runtimeType.toString());
}
// try to get the manifest file
@ -1722,9 +1722,12 @@ class MacOSInAppWebViewController extends PlatformInAppWebViewController
icon["src"], icon["rel"], icon["sizes"], true));
}
}
} on FormatException catch (_) {
/// The [manifestResponse] might not has a valid JSON string, catch and
/// ignore the error
} catch (e) {
developer.log(
"Cannot get favicons from Manifest file. It might not have a valid format: " +
e.toString(),
error: e,
name: runtimeType.toString());
}
}

View File

@ -1,6 +1,6 @@
name: flutter_inappwebview_macos
description: macOS implementation of the flutter_inappwebview plugin.
version: 1.0.4
version: 1.0.5
homepage: https://inappwebview.dev/
repository: https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_macos
issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues