cordova-android icon indicating copy to clipboard operation
cordova-android copied to clipboard

deprecation warnings on java code

Open zoranmil opened this issue 2 years ago • 3 comments

Bug Report

cordova's java code presents 17 deprecation warnings they should be evaluated to replace the code or ignore the warning

Problem

What is expected to happen?

What does actually happen?

Information

Task :CordovaLib:compileReleaseJavaWithJavac E:\kopija\zoran\platforms\android\CordovaLib\src\org\apache\cordova\CordovaActivity.java:132: warning: [deprecation] FLAG_FULLSCREEN in LayoutParams has been deprecated getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, ^ E:\kopija\zoran\platforms\android\CordovaLib\src\org\apache\cordova\CordovaActivity.java:133: warning: [deprecation] FLAG_FULLSCREEN in LayoutParams has been deprecated WindowManager.LayoutParams.FLAG_FULLSCREEN); ^ E:\kopija\zoran\platforms\android\CordovaLib\src\org\apache\cordova\CordovaActivity.java:136: warning: [deprecation] FLAG_FORCE_NOT_FULLSCREEN in LayoutParams has been deprecated getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN, ^ E:\kopija\zoran\platforms\android\CordovaLib\src\org\apache\cordova\CordovaActivity.java:137: warning: [deprecation] FLAG_FORCE_NOT_FULLSCREEN in LayoutParams has been deprecated WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); ^ E:\kopija\zoran\platforms\android\CordovaLib\src\org\apache\cordova\CordovaInterfaceImpl.java:69: warning: [deprecation] startActivityForResult(Intent,int) in ComponentActivity has been deprecated activity.startActivityForResult(intent, requestCode); ^ E:\kopija\zoran\platforms\android\CordovaLib\src\org\apache\cordova\CordovaInterfaceImpl.java:222: warning: [deprecation] onRequestPermissionResult(int,String[],int[]) in CordovaPlugin has been deprecated callback.first.onRequestPermissionResult(callback.second, permissions, grantResults); ^ E:\kopija\zoran\platforms\android\CordovaLib\src\org\apache\cordova\CordovaActivity.java:337: warning: [deprecation] SYSTEM_UI_FLAG_LAYOUT_STABLE in View has been deprecated final int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE ^ E:\kopija\zoran\platforms\android\CordovaLib\src\org\apache\cordova\CordovaActivity.java:338: warning: [deprecation] SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION in View has been deprecated | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION ^ E:\kopija\zoran\platforms\android\CordovaLib\src\org\apache\cordova\CordovaActivity.java:339: warning: [deprecation] SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN in View has been deprecated | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN ^ E:\kopija\zoran\platforms\android\CordovaLib\src\org\apache\cordova\CordovaActivity.java:340: warning: [deprecation] SYSTEM_UI_FLAG_HIDE_NAVIGATION in View has been deprecated | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION ^ E:\kopija\zoran\platforms\android\CordovaLib\src\org\apache\cordova\CordovaActivity.java:341: warning: [deprecation] SYSTEM_UI_FLAG_FULLSCREEN in View has been deprecated | View.SYSTEM_UI_FLAG_FULLSCREEN ^ E:\kopija\zoran\platforms\android\CordovaLib\src\org\apache\cordova\CordovaActivity.java:342: warning: [deprecation] SYSTEM_UI_FLAG_IMMERSIVE_STICKY in View has been deprecated | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; ^ E:\kopija\zoran\platforms\android\CordovaLib\src\org\apache\cordova\CordovaActivity.java:344: warning: [deprecation] setSystemUiVisibility(int) in View has been deprecated getWindow().getDecorView().setSystemUiVisibility(uiOptions); ^ E:\kopija\zoran\platforms\android\CordovaLib\src\org\apache\cordova\CordovaActivity.java:349: warning: [deprecation] startActivityForResult(Intent,int,Bundle) in ComponentActivity has been deprecated public void startActivityForResult(Intent intent, int requestCode, Bundle options) { ^ E:\kopija\zoran\platforms\android\CordovaLib\src\org\apache\cordova\CordovaActivity.java:352: warning: [deprecation] startActivityForResult(Intent,int,Bundle) in ComponentActivity has been deprecated super.startActivityForResult(intent, requestCode, options); ^ E:\kopija\zoran\platforms\android\CordovaLib\src\org\apache\cordova\engine\SystemCookieManager.java:38: warning: [deprecation] setAcceptFileSchemeCookies(boolean) in CookieManager has been deprecated cookieManager.setAcceptFileSchemeCookies(true); ^ E:\kopija\zoran\platforms\android\CordovaLib\src\org\apache\cordova\PermissionHelper.java:83: warning: [deprecation] onRequestPermissionResult(int,String[],int[]) in CordovaPlugin has been deprecated plugin.onRequestPermissionResult(requestCode, permissions, requestResults); ^ 17 warnings

Command or Code

Environment, Platform, Device

windows 10

Version information

cordova 10.1.1 no plugins test aplication Android studio ARCTIC FOX 2020.3.1

Checklist

  • [ x ] I searched for existing GitHub issues
  • [ x ] I updated all Cordova tooling to most recent version
  • [ x ] I included all the necessary information above

zoranmil avatar Dec 24 '21 19:12 zoranmil

those are just warnings, are you getting some error that prevents your app from building?

jcesarmobile avatar Jan 04 '22 12:01 jcesarmobile

Yes only warnings Build success

zoranmil avatar Jan 04 '22 12:01 zoranmil

Just some research information:

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,

Replacement: https://developer.android.com/reference/android/view/WindowInsetsController#hide(int) (Replacement requires API >= 30)

FLAG_FORCE_NOT_FULLSCREEN

An "accidental API" not intended to be used by third-party apps with no replacement, but was used to override FLAG_FULLSCREEN so any usages can be probably changed to use FLAG_FULLSCREEN directly.

CordovaInterfaceImpl.java:69: warning: [deprecation] startActivityForResult(Intent,int) in ComponentActivity has been deprecated

https://developer.android.com/reference/androidx/activity/ComponentActivity#startActivityForResult(android.content.Intent,int) (believe this can be refactored at any time)

SYSTEM_UI_FLAG_LAYOUT_STABLE

https://developer.android.com/reference/android/view/View#SYSTEM_UI_FLAG_LAYOUT_STABLE (Replacement requires API >= 30)

SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION

https://developer.android.com/reference/android/view/View#SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION (Replacement requires API >= 30)

SYSTEM_UI_FLAG_IMMERSIVE_STICKY

https://developer.android.com/reference/android/view/View#SYSTEM_UI_FLAG_IMMERSIVE_STICKY (Replacement requires API >= 30)

getWindow().getDecorView().setSystemUiVisibility(uiOptions);

https://developer.android.com/reference/android/view/View.html#setSystemUiVisibility(int) (Replacement requires API >= 30)

setAcceptFileSchemeCookies

https://developer.android.com/reference/android/webkit/CookieManager#setAcceptFileSchemeCookies(boolean)

This one is covered by cordova-android@10 which by default uses the WebViewAssetLoader, so the replacement is already implemented. But we can't remove this usage until we decide to remove support for the file:// scheme.

onRequestPermissionResult

This is a deprecation within the cordova API. It will remain until we decide to forcefully remove the deprecated API (and force plugin authors to update their code accordingly)

As most of these requires API >= 30 to properly remove, it will be some time before we can actually act on any of these deprecation warnings. For reference, Cordova supports API >= 22.

breautek avatar Feb 05 '22 01:02 breautek