mirror of
https://github.com/apache/cordova-android.git
synced 2025-03-04 00:13:20 +08:00
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:
parent
c93f93f637
commit
6402e7b755
@ -41,7 +41,7 @@ allprojects {
|
|||||||
//This replaces project.properties w.r.t. build settings
|
//This replaces project.properties w.r.t. build settings
|
||||||
project.ext {
|
project.ext {
|
||||||
defaultBuildToolsVersion="29.0.2" //String
|
defaultBuildToolsVersion="29.0.2" //String
|
||||||
defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4
|
defaultMinSdkVersion=22 //Integer - Minimum requirement is Android 5.1
|
||||||
defaultTargetSdkVersion=29 //Integer - We ALWAYS target the latest by default
|
defaultTargetSdkVersion=29 //Integer - We ALWAYS target the latest by default
|
||||||
defaultCompileSdkVersion=29 //Integer - We ALWAYS compile with the latest by default
|
defaultCompileSdkVersion=29 //Integer - We ALWAYS compile with the latest by default
|
||||||
}
|
}
|
||||||
|
@ -223,22 +223,6 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
|
|
||||||
ELSE NOTHING! DON'T MESS WITH THE VERSION CODE IF YOU DON'T HAVE TO!
|
|
||||||
|
|
||||||
else if (!cdvVersionCode) {
|
|
||||||
def minSdkVersion = cdvMinSdkVersion ?: privateHelpers.extractIntFromManifest("minSdkVersion")
|
|
||||||
// Vary versionCode by the two most common API levels:
|
|
||||||
// 14 is ICS, which is the lowest API level for many apps.
|
|
||||||
// 20 is Lollipop, which is the lowest API level for the updatable system webview.
|
|
||||||
if (minSdkVersion >= 20) {
|
|
||||||
defaultConfig.versionCode += 9
|
|
||||||
} else if (minSdkVersion >= 14) {
|
|
||||||
defaultConfig.versionCode += 8
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_1_6
|
sourceCompatibility JavaVersion.VERSION_1_6
|
||||||
|
@ -62,7 +62,7 @@ android {
|
|||||||
|
|
||||||
// For the Android Cordova Lib, we will hardcode the minSdkVersion and not allow changes.
|
// For the Android Cordova Lib, we will hardcode the minSdkVersion and not allow changes.
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 19
|
minSdkVersion 22
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
|
@ -31,17 +31,12 @@ class SystemCookieManager implements ICordovaCookieManager {
|
|||||||
protected final WebView webView;
|
protected final WebView webView;
|
||||||
private final CookieManager cookieManager;
|
private final CookieManager cookieManager;
|
||||||
|
|
||||||
//Added because lint can't see the conditional RIGHT ABOVE this
|
|
||||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
|
||||||
public SystemCookieManager(WebView webview) {
|
public SystemCookieManager(WebView webview) {
|
||||||
webView = webview;
|
webView = webview;
|
||||||
cookieManager = CookieManager.getInstance();
|
cookieManager = CookieManager.getInstance();
|
||||||
|
|
||||||
cookieManager.setAcceptFileSchemeCookies(true);
|
cookieManager.setAcceptFileSchemeCookies(true);
|
||||||
|
cookieManager.setAcceptThirdPartyCookies(webView, true);
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
||||||
cookieManager.setAcceptThirdPartyCookies(webView, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCookiesEnabled(boolean accept) {
|
public void setCookiesEnabled(boolean accept) {
|
||||||
@ -58,16 +53,10 @@ class SystemCookieManager implements ICordovaCookieManager {
|
|||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void clearCookies() {
|
public void clearCookies() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
cookieManager.removeAllCookies(null);
|
||||||
cookieManager.removeAllCookies(null);
|
|
||||||
} else {
|
|
||||||
cookieManager.removeAllCookie();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flush() {
|
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)
|
if (consoleMessage.message() != null)
|
||||||
LOG.d(LOG_TAG, "%s: Line %d : %s" , consoleMessage.sourceId() , consoleMessage.lineNumber(), consoleMessage.message());
|
LOG.d(LOG_TAG, "%s: Line %d : %s" , consoleMessage.sourceId() , consoleMessage.lineNumber(), consoleMessage.message());
|
||||||
return super.onConsoleMessage(consoleMessage);
|
return super.onConsoleMessage(consoleMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -176,7 +176,6 @@ public class SystemWebChromeClient extends WebChromeClient {
|
|||||||
{
|
{
|
||||||
geolocation.requestPermissions(0);
|
geolocation.requestPermissions(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// API level 7 is required for this, see if we could lower this using something else
|
// 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.
|
* @return View The progress view.
|
||||||
*/
|
*/
|
||||||
public View getVideoLoadingProgressView() {
|
public View getVideoLoadingProgressView() {
|
||||||
|
|
||||||
if (mVideoProgressView == null) {
|
if (mVideoProgressView == null) {
|
||||||
// Create a new Loading view programmatically.
|
// Create a new Loading view programmatically.
|
||||||
|
|
||||||
@ -218,36 +216,9 @@ public class SystemWebChromeClient extends WebChromeClient {
|
|||||||
|
|
||||||
mVideoProgressView = layout;
|
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
|
@Override
|
||||||
public boolean onShowFileChooser(WebView webView, final ValueCallback<Uri[]> filePathsCallback, final WebChromeClient.FileChooserParams fileChooserParams) {
|
public boolean onShowFileChooser(WebView webView, final ValueCallback<Uri[]> filePathsCallback, final WebChromeClient.FileChooserParams fileChooserParams) {
|
||||||
// Check if multiple-select is specified
|
// Check if multiple-select is specified
|
||||||
@ -288,7 +259,6 @@ public class SystemWebChromeClient extends WebChromeClient {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
|
||||||
@Override
|
@Override
|
||||||
public void onPermissionRequest(final PermissionRequest request) {
|
public void onPermissionRequest(final PermissionRequest request) {
|
||||||
LOG.d(LOG_TAG, "onPermissionRequest: " + Arrays.toString(request.getResources()));
|
LOG.d(LOG_TAG, "onPermissionRequest: " + Arrays.toString(request.getResources()));
|
||||||
|
@ -113,7 +113,6 @@ public class SystemWebViewClient extends WebViewClient {
|
|||||||
* @param request
|
* @param request
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
|
||||||
public void onReceivedClientCertRequest (WebView view, ClientCertRequest request)
|
public void onReceivedClientCertRequest (WebView view, ClientCertRequest request)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -334,7 +333,7 @@ public class SystemWebViewClient extends WebViewClient {
|
|||||||
// Allow plugins to intercept WebView requests.
|
// Allow plugins to intercept WebView requests.
|
||||||
Uri remappedUri = resourceApi.remapUri(origUri);
|
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);
|
CordovaResourceApi.OpenForReadResult result = resourceApi.openForRead(remappedUri, true);
|
||||||
return new WebResourceResponse(result.mimeType, "UTF-8", result.inputStream);
|
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());
|
return "content".equals(uri.getScheme());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ android {
|
|||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "org.apache.cordova.unittests"
|
applicationId "org.apache.cordova.unittests"
|
||||||
minSdkVersion 19
|
minSdkVersion 22
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
|
@ -24,7 +24,7 @@ android {
|
|||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "org.apache.cordova.unittests"
|
applicationId "org.apache.cordova.unittests"
|
||||||
minSdkVersion 19
|
minSdkVersion 22
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
|
Loading…
Reference in New Issue
Block a user