Bump minSdkVersion to 22 and drop pre-Lollipop specific code (#915)

* feat: bump minSdkVersion to 22

BREAKING CHANGE: drop KitKat support

* chore: remove obsolete comment

* feat: remove pre-Lollipop specific code

* chore: remove KitKat from needsKitKatContentUrlFix

* chore: other minor cleanup
This commit is contained in:
Bas Bosman
2020-04-03 19:54:08 +02:00
committed by GitHub
parent c93f93f637
commit 6402e7b755
8 changed files with 11 additions and 69 deletions
+1 -1
View File
@@ -62,7 +62,7 @@ android {
// For the Android Cordova Lib, we will hardcode the minSdkVersion and not allow changes.
defaultConfig {
minSdkVersion 19
minSdkVersion 22
}
sourceSets {
@@ -31,17 +31,12 @@ class SystemCookieManager implements ICordovaCookieManager {
protected final WebView webView;
private final CookieManager cookieManager;
//Added because lint can't see the conditional RIGHT ABOVE this
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public SystemCookieManager(WebView webview) {
webView = webview;
cookieManager = CookieManager.getInstance();
cookieManager.setAcceptFileSchemeCookies(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
cookieManager.setAcceptThirdPartyCookies(webView, true);
}
cookieManager.setAcceptThirdPartyCookies(webView, true);
}
public void setCookiesEnabled(boolean accept) {
@@ -58,16 +53,10 @@ class SystemCookieManager implements ICordovaCookieManager {
@SuppressWarnings("deprecation")
public void clearCookies() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
cookieManager.removeAllCookies(null);
} else {
cookieManager.removeAllCookie();
}
cookieManager.removeAllCookies(null);
}
public void flush() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
cookieManager.flush();
}
cookieManager.flush();
}
};
@@ -155,7 +155,7 @@ public class SystemWebChromeClient extends WebChromeClient {
{
if (consoleMessage.message() != null)
LOG.d(LOG_TAG, "%s: Line %d : %s" , consoleMessage.sourceId() , consoleMessage.lineNumber(), consoleMessage.message());
return super.onConsoleMessage(consoleMessage);
return super.onConsoleMessage(consoleMessage);
}
@Override
@@ -176,7 +176,6 @@ public class SystemWebChromeClient extends WebChromeClient {
{
geolocation.requestPermissions(0);
}
}
// API level 7 is required for this, see if we could lower this using something else
@@ -199,7 +198,6 @@ public class SystemWebChromeClient extends WebChromeClient {
* @return View The progress view.
*/
public View getVideoLoadingProgressView() {
if (mVideoProgressView == null) {
// Create a new Loading view programmatically.
@@ -218,36 +216,9 @@ public class SystemWebChromeClient extends WebChromeClient {
mVideoProgressView = layout;
}
return mVideoProgressView;
return mVideoProgressView;
}
// <input type=file> support:
// openFileChooser() is for pre KitKat and in KitKat mr1 (it's known broken in KitKat).
// For Lollipop, we use onShowFileChooser().
public void openFileChooser(ValueCallback<Uri> uploadMsg) {
this.openFileChooser(uploadMsg, "*/*");
}
public void openFileChooser( ValueCallback<Uri> uploadMsg, String acceptType ) {
this.openFileChooser(uploadMsg, acceptType, null);
}
public void openFileChooser(final ValueCallback<Uri> uploadMsg, String acceptType, String capture)
{
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
parentEngine.cordova.startActivityForResult(new CordovaPlugin() {
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
Uri result = intent == null || resultCode != Activity.RESULT_OK ? null : intent.getData();
LOG.d(LOG_TAG, "Receive file chooser URL: " + result);
uploadMsg.onReceiveValue(result);
}
}, intent, FILECHOOSER_RESULTCODE);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public boolean onShowFileChooser(WebView webView, final ValueCallback<Uri[]> filePathsCallback, final WebChromeClient.FileChooserParams fileChooserParams) {
// Check if multiple-select is specified
@@ -288,7 +259,6 @@ public class SystemWebChromeClient extends WebChromeClient {
return true;
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void onPermissionRequest(final PermissionRequest request) {
LOG.d(LOG_TAG, "onPermissionRequest: " + Arrays.toString(request.getResources()));
@@ -113,7 +113,6 @@ public class SystemWebViewClient extends WebViewClient {
* @param request
*/
@Override
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void onReceivedClientCertRequest (WebView view, ClientCertRequest request)
{
@@ -334,7 +333,7 @@ public class SystemWebViewClient extends WebViewClient {
// Allow plugins to intercept WebView requests.
Uri remappedUri = resourceApi.remapUri(origUri);
if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsKitKatContentUrlFix(origUri)) {
if (!origUri.equals(remappedUri) || needsSpecialsInAssetUrlFix(origUri) || needsContentUrlFix(origUri)) {
CordovaResourceApi.OpenForReadResult result = resourceApi.openForRead(remappedUri, true);
return new WebResourceResponse(result.mimeType, "UTF-8", result.inputStream);
}
@@ -349,7 +348,7 @@ public class SystemWebViewClient extends WebViewClient {
}
}
private static boolean needsKitKatContentUrlFix(Uri uri) {
private static boolean needsContentUrlFix(Uri uri) {
return "content".equals(uri.getScheme());
}