Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions flutter_inappwebview_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## 1.2.0-beta.3

- Fixed Java deprecation warnings in Android native code: replaced `new Long(String)` with `Long.parseLong`, `new Handler()` with `new Handler(Looper.getMainLooper())`, gated `CookieManager.removeSessionCookie()` behind pre-`LOLLIPOP` SDK check, and annotated methods retaining pre-`LOLLIPOP` `CookieSyncManager` / `CookieManager.removeAllCookie` / `removeSessionCookie` fallbacks with `@SuppressWarnings("deprecation")` [#2641](https://github.com/pichillilorenzo/flutter_inappwebview/issues/2641)
- Updated flutter_inappwebview_platform_interface version to ^1.4.0-beta.3
- Updated native dependencies:
- implementation from `'androidx.webkit:webkit:1.12.0'` to `'androidx.webkit:webkit:1.14.0'`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result
String domain = (String) call.argument("domain");
String path = (String) call.argument("path");
String expiresDateString = (String) call.argument("expiresDate");
Long expiresDate = (expiresDateString != null ? new Long(expiresDateString) : null);
Long expiresDate = (expiresDateString != null ? Long.parseLong(expiresDateString) : null);
Integer maxAge = (Integer) call.argument("maxAge");
Boolean isSecure = (Boolean) call.argument("isSecure");
Boolean isHttpOnly = (Boolean) call.argument("isHttpOnly");
Expand Down Expand Up @@ -145,6 +145,7 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result
return cookieManager;
}

@SuppressWarnings("deprecation")
public void setCookie(String url,
String name,
String value,
Expand Down Expand Up @@ -288,6 +289,7 @@ public List<Map<String, Object>> getCookies(final String url) {

}

@SuppressWarnings("deprecation")
public void deleteCookie(String url, String name, String domain, String path, final MethodChannel.Result result) {
cookieManager = getCookieManager();
if (cookieManager == null) {
Expand Down Expand Up @@ -324,6 +326,7 @@ else if (plugin != null) {
}
}

@SuppressWarnings("deprecation")
public void deleteCookies(String url, String domain, String path, final MethodChannel.Result result) {
cookieManager = getCookieManager();
if (cookieManager == null) {
Expand Down Expand Up @@ -368,6 +371,7 @@ public void deleteCookies(String url, String domain, String path, final MethodCh
result.success(true);
}

@SuppressWarnings("deprecation")
public void deleteAllCookies(final MethodChannel.Result result) {
cookieManager = getCookieManager();
if (cookieManager == null) {
Expand Down Expand Up @@ -397,6 +401,7 @@ else if (plugin != null) {
}
}

@SuppressWarnings("deprecation")
public void removeSessionCookies(final MethodChannel.Result result) {
cookieManager = getCookieManager();
if (cookieManager == null) {
Expand Down Expand Up @@ -426,6 +431,7 @@ else if (plugin != null) {
}
}

@SuppressWarnings("deprecation")
public void flush(MethodChannel.Result result) {
cookieManager = getCookieManager();
if (cookieManager == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
@Nullable
public Map<String, Object> contextMenu = null;
public Handler mainLooperHandler = new Handler(getWebViewLooper());
static Handler mHandler = new Handler();
static Handler mHandler = new Handler(Looper.getMainLooper());

public Runnable checkScrollStoppedTask;
public int initialPositionScrollStoppedTask;
Expand Down Expand Up @@ -337,7 +337,7 @@ else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
if (customSettings.clearCache)
clearAllCache();
else if (customSettings.clearSessionCache)
CookieManager.getInstance().removeSessionCookie();
clearSessionCookies();

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
CookieManager.getInstance().setAcceptThirdPartyCookies(this, customSettings.thirdPartyCookiesEnabled);
Expand Down Expand Up @@ -636,6 +636,7 @@ public void prepareAndAddUserScripts() {
this.userContentController.addUserOnlyScripts(this.initialUserOnlyScripts);
}

@SuppressWarnings("deprecation")
public void setIncognito(boolean enabled) {
WebSettings settings = getSettings();
if (enabled) {
Expand Down Expand Up @@ -727,6 +728,7 @@ public boolean isLoading() {
* @deprecated
*/
@Deprecated
@SuppressWarnings("deprecation")
private void clearCookies() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
CookieManager.getInstance().removeAllCookies(new ValueCallback<Boolean>() {
Expand All @@ -740,6 +742,15 @@ public void onReceiveValue(Boolean aBoolean) {
}
}

@SuppressWarnings("deprecation")
private void clearSessionCookies() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
CookieManager.getInstance().removeSessionCookies(null);
} else {
CookieManager.getInstance().removeSessionCookie();
}
}

/**
* @deprecated
*/
Expand Down Expand Up @@ -919,7 +930,7 @@ else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
if (newSettingsMap.get("clearCache") != null && newCustomSettings.clearCache)
clearAllCache();
else if (newSettingsMap.get("clearSessionCache") != null && newCustomSettings.clearSessionCache)
CookieManager.getInstance().removeSessionCookie();
clearSessionCookies();

if (newSettingsMap.get("thirdPartyCookiesEnabled") != null && customSettings.thirdPartyCookiesEnabled != newCustomSettings.thirdPartyCookiesEnabled && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
CookieManager.getInstance().setAcceptThirdPartyCookies(this, newCustomSettings.thirdPartyCookiesEnabled);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ public void onPageStarted(WebView view, String url, Bitmap favicon) {
}
}

@SuppressWarnings("deprecation")
public void onPageFinished(WebView view, String url) {
final InAppWebView webView = (InAppWebView) view;
webView.isLoading = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ public void onPageStarted(WebView view, String url, Bitmap favicon) {
}
}

@SuppressWarnings("deprecation")
public void onPageFinished(WebView view, String url) {
final InAppWebView webView = (InAppWebView) view;
webView.isLoading = false;
Expand Down