Conversation
Warning Messages: - "'onActivityResult(Int, Int, Intent?): Unit' is deprecated. Deprecated in Java" - "'onActivityResult(Int, Int, Intent?): Unit' is deprecated. Overrides deprecated member in 'androidx.activity.ComponentActivity'. Deprecated in Java" - "'startActivityForResult(Intent!, Int): Unit' is deprecated. Deprecated in Java" - "'showPhotoPickerForResult(Activity!, MediaBrowserType, SiteModel?, Int?): Unit' is deprecated. Deprecated in Java" - "'handleMediaPickerResultForStories(Intent, Activity?, SiteModel?, PagePostCreationSourcesDetail): Boolean' is deprecated. Use rather the other handle method and the live data navigation." This deprecated warnings are suppressed, that is, instead them being resolved, since a resolution would require a proper migration. Explanation: "This method is deprecated. This method has been deprecated in favor of using the Activity Result API which brings increased type safety via an ActivityResultContract and the prebuilt contracts for common intents available in androidx.activity.result.contract.ActivityResultContracts, provides hooks for testing, and allow receiving results in separate, testable classes independent from your activity. Use registerForActivityResult with the appropriate ActivityResultContract and handling the result in the callback." For more info see: - androidx.fragment.app.Fragment.onActivityResult (Docs): https://developer.android.com/reference/androidx/fragment/app/ Fragment#onActivityResult(int,int,android.content.Intent) - androidx.fragment.app.Fragment.startActivityForResult (Docs): https://developer.android.com/reference/androidx/fragment/app/ Fragment#startActivityForResult(android.content.Intent,int) - androidx.fragment.app.FragmentActivity.onActivityResult (Docs): https://developer.android.com/reference/androidx/fragment/app/ FragmentActivity#onActivityResult(int,int,android.content.Intent) - androidx.activity.ComponentActivity.startActivityForResult (Docs): https://developer.android.com/reference/androidx/activity/ ComponentActivity#startActivityForResult(android.content.Intent,int)
Warning Message: "'fromHtml(String!): Spanned!' is deprecated. Deprecated in Java" Replacing 'Html.fromHtml(html)' with the 'HtmlCompat.fromHtml (html, HtmlCompat.FROM_HTML_MODE_LEGACY)' compat related version is the recommended action to resolve this kind of deprecated warnings.
Warning Messages: - "'setTargetFragment(Fragment?, Int): Unit' is deprecated. Deprecated in Java" - "'getter for targetFragment: Fragment?' is deprecated. Deprecated in Java" These deprecated warnings are suppressed, that is, instead of them being resolved, since a resolution would require a proper migration. Explanation: - "Instead of using a target fragment to pass results, the fragment requesting a result should use FragmentManager.setFragmentResultListener (String, LifecycleOwner, FragmentResultListener) to register a FragmentResultListener with a requestKey using its parent fragment manager. The fragment delivering a result should then call FragmentManager.setFragmentResult(String, Bundle) using the same requestKey. Consider using setArguments to pass the requestKey if you need to support dynamic request keys." - "Instead of using a target fragment to pass results, use FragmentManager.setFragmentResult(String, Bundle) to deliver results to FragmentResultListener instances registered by other fragments via FragmentManager.setFragmentResultListener(String, LifecycleOwner, FragmentResultListener)." For more info see: - android.app.Fragment.setTargetFragment (Docs): https://developer.android.com/reference/android/app/ Fragment#setTargetFragment(android.app.Fragment,%20int) - android.app.Fragment.getTargetFragment (Docs): https://developer.android.com/reference/android/app/ Fragment#getTargetFragment()
Warning Message: "'onActivityCreated(Bundle?): Unit' is deprecated. Deprecated in Java" These deprecated warnings are suppressed, that is, instead of being resolved, since a resolution would require a proper migration. Explanation: "Use onViewCreated(View, Bundle) for code touching the view created by onCreateView and onCreate(Bundle) for other initialization. To get a callback specifically when a Fragment activity's Activity.onCreate(Bundle) is called, register a androidx.lifecycle.LifecycleObserver on the Activity's Lifecycle in onAttach(Context), removing it when it receives the Lifecycle.State.CREATED callback." For more info see: - androidx.fragment.app.Fragment.onActivityCreated (Docs): https://developer.android.com/reference/androidx/fragment/app/ Fragment#onActivityCreated(android.os.Bundle)
Warning Message: "'FragmentPagerAdapter' is deprecated. Deprecated in Java" These deprecated warnings are suppressed, that is, instead of being resolved, since a resolution would require a proper migration. You will also notice that I didn't suppressed the deprecated warning both, on the file level and closer to the deprecation itself. I will be doing the file level suppression on the 'ProgressDialog', which is yet to be suppressed. Explanation: - "Use FragmentPagerAdapter(FragmentManager, int) with BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT" - This class is deprecated. Switch to androidx.viewpager2.widget.ViewPager2 and use androidx.viewpager2.adapter.FragmentStateAdapter instead. For more info see: - androidx.fragment.app.FragmentPagerAdapter (Docs): https://developer.android.com/reference/androidx/fragment/app/ FragmentPagerAdapter
Warning Messages: - "'ProgressDialog' is deprecated. Deprecated in Java" - "'constructor ProgressDialog(Context!)' is deprecated. Deprecated in Java" - "'show(Context!, CharSequence!, CharSequence!, Boolean): ProgressDialog!' is deprecated. Deprecated in Java" - "'show(Context!, CharSequence!, CharSequence!, Boolean, Boolean): ProgressDialog!' is deprecated. Deprecated in Java" - "'setter for isIndeterminate: Boolean' is deprecated. Deprecated in Java" - "'setMessage(CharSequence!): Unit' is deprecated. Deprecated in Java" These deprecated warnings are suppressed, that is, instead of being resolved, since a resolution would require a proper migration. You will also notice that I suppressed the deprecated warning both, on the file level and closer to the deprecation itself. In addition to that, you will notice that I suppressed the deprecated warning for other such warnings, like 'StringEscapeUtils' and 'PhotoPickerActivity'. I did that because suppressing on the file level was necessary due to the 'android.app.ProgressDialog' import that can't be suppressed any other way. But, when doing so, every deprecated warning is suppressed as well. At which point the deprecated information is lost. This way, adding first the '@Suppress("DEPRECATION")' closer to source and then adding it on the file level makes sure that this information is not lost, at least for the existing code. Explanation: "This class was deprecated in API level 26. ProgressDialog is a modal dialog, which prevents the user from interacting with the app. Instead of using this class, you should use a progress indicator like ProgressBar, which can be embedded in your app's UI. Alternatively, you can use a notification to inform the user of the task's progress." Docs: https://developer.android.com/reference/android/app/ProgressDialog
Warning Message: "'CommentsDetailActivity' is deprecated. Deprecated in Java" These deprecated warnings are suppressed, that is, instead of being resolved, since a resolution would require a proper migration. Explanation: See KDoc on 'CommentsDetailActivity' class. "Comments are being refactored as part of Comments Unification project. If you are adding any features or modifying this class, please ping develric or klymyam"
Warning Messages: - "'LabelVisibilityMode' is deprecated. Deprecated in Java" - "'OnNavigationItemSelectedListener' is deprecated. Deprecated in Java" - "'setOnNavigationItemSelectedListener (BottomNavigationView.OnNavigationItemSelectedListener?): Unit' is deprecated. Deprecated in Java" - "'OnNavigationItemReselectedListener' is deprecated. Deprecated in Java" - "'setOnNavigationItemReselectedListener (BottomNavigationView.OnNavigationItemReselectedListener?): Unit' is deprecated. Deprecated in Java" Replacing the deprecated code with the 'NavigationBarView' related version is the recommended action to resolve this kind of deprecated warnings. More more info see: - LabelVisibilityMode (Docs): https://developer.android.com/reference/com/google/android/material/ bottomnavigation/LabelVisibilityMode - BottomNavigationView.OnNavigationItemSelectedListener (Docs): https://developer.android.com/reference/com/google/android/material/ bottomnavigation/BottomNavigationView.OnNavigationItemSelectedListener - BottomNavigationView.OnNavigationItemReselectedListener (Docs): https://developer.android.com/reference/com/google/android/material/ bottomnavigation/BottomNavigationView.OnNavigationItemReselectedListener
Warning Messages: - "'ExtractorMediaSource' is deprecated. Deprecated in Java" - "'DefaultHttpDataSourceFactory' is deprecated. Deprecated in Java" - "'getter for defaultRequestProperties: HttpDataSource.RequestProperties' is deprecated. Deprecated in Java" - "'createMediaSource(Uri): DashMediaSource' is deprecated. Deprecated in Java" - "'createMediaSource(Uri): SsMediaSource' is deprecated. Deprecated in Java" - "'createMediaSource(Uri): HlsMediaSource' is deprecated. Deprecated in Java" - "'Factory' is deprecated. Deprecated in Java" - "'createMediaSource(Uri): ExtractorMediaSource' is deprecated. Deprecated in Java" These deprecated warnings are suppressed, that is, instead of being resolved, since a resolution would require a proper migration. For more info see: - Exoplayer Developer Guide (Docs): https://exoplayer.dev
Warning Message: "'requestPermissions(Array<(out) String!>, Int): Unit' is deprecated. Deprecated in Java" These deprecated warnings are suppressed, that is, instead of being resolved, since a resolution would require a proper migration. For more info see: - androidx.fragment.app.Fragment.requestPermissions (Docs): https://developer.android.com/reference/androidx/fragment/app/ Fragment#requestPermissions(java.lang.String[],int)
Warning Message: "'getExternalStoragePublicDirectory(String!): File!' is deprecated. Deprecated in Java" These deprecated warnings are suppressed, that is, instead of being resolved, since a resolution would require a proper migration. For more info see: - android.os.Environment.getExternalStoragePublicDirectory (Docs): https://developer.android.com/reference/android/os/ Environment#getExternalStoragePublicDirectory(java.lang.String)
Warning Message: "'PhotoPickerActivity' is deprecated.
Deprecated in Java"
These deprecated warnings are suppressed, that is, instead of being
resolved, since a resolution would require a proper migration.
Explanation: See Javadoc on 'PhotoPickerActivity' class.
"This class is being refactored, if you implement any change, please
also update {@link org.wordpress.android.ui.mediapicker.
MediaPickerActivity}"
Warning Messages: - "'AsyncTask<Params : Any!, Progress : Any!, Result : Any!>' is deprecated. Deprecated in Java" - "'THREAD_POOL_EXECUTOR: Executor!' is deprecated. Deprecated in Java" - "'constructor AsyncTask<Params : Any!, Progress : Any!, Result : Any!>()' is deprecated. Deprecated in Java" - "'executeOnExecutor(Executor!, vararg Void!): AsyncTask<Void!, Void!, List<NoteBlock>?>!' is deprecated. Deprecated in Java" These deprecated warnings are suppressed, that is, instead of being resolved, since a resolution would require a proper migration. You will also notice that I suppressed the deprecated warning both, on the file level and closer to the deprecation itself. In addition to that, you will notice that I suppressed the deprecated warning for other such warnings, like 'GeneratedNoteBlock'. I did that because suppressing on the file level was necessary due to the 'android.os.AsyncTask' import that can't be suppressed any other way. But, when doing so, every deprecated warning is suppressed as well. At which point the deprecated information is lost. This way, adding first the '@Suppress ("DEPRECATION")' closer to source and then adding it on the file level makes sure that this information is not lost, at least for the existing code. Explanation: "This class was deprecated in API level 30. Use the standard java.util.concurrent or Kotlin concurrency utilities instead."
Warning Messages: - "'BaseTarget<Z : Any!>' is deprecated. Deprecated in Java" - "'ViewTarget<T : View!, Z : Any!>' is deprecated. Deprecated in Java" - "'getter for opacity: Int' is deprecated. Deprecated in Java" These deprecated warnings are suppressed, that is, instead of being resolved, since a resolution would require a proper migration. For more info see: - Glide Guide (Docs): https://bumptech.github.io/glide
Warning Message: "'allowScanningByMediaScanner(): Unit' is deprecated. Deprecated in Java" These deprecated warnings are suppressed, that is, instead of being resolved, since a resolution would require a proper migration. For more info see: - android.app.DownloadManager.Request.allowScanningByMediaScanner (Doc): https://developer.android.com/reference/android/app/ DownloadManager.Request#allowScanningByMediaScanner()
Warning Messages: - "'getter for systemWindowInsetTop: Int' is deprecated. Deprecated in Java" - "'consumeSystemWindowInsets(): WindowInsetsCompat' is deprecated. Deprecated in Java" - "'getter for defaultDisplay: Display!' is deprecated. Deprecated in Java" - "'getSize(Point!): Unit' is deprecated. Deprecated in Java" - "'setter for systemUiVisibility: Int' is deprecated. Deprecated in Java" - "'getter for systemUiVisibility: Int' is deprecated. Deprecated in Java" - "'SYSTEM_UI_FLAG_LIGHT_STATUS_BAR: Int' is deprecated. Deprecated in Java" - "'SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR: Int' is deprecated. Deprecated in Java" - "'SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN: Int' is deprecated. Deprecated in Java" - "'SYSTEM_UI_FLAG_LAYOUT_STABLE: Int' is deprecated. Deprecated in Java" These deprecated warnings are suppressed, that is, instead of being resolved, since a resolution would require a proper migration. For more info see: - android.view.WindowInsets.getSystemWindowInsetTop (Docs): https://developer.android.com/reference/android/view/ WindowInsets#getSystemWindowInsetTop() - android.view.WindowInsets.consumeSystemWindowInsets (Docs): https://developer.android.com/reference/android/view/ WindowInsets#consumeSystemWindowInsets() - android.view.WindowManager.getDefaultDisplay (Docs): https://developer.android.com/reference/android/view/ WindowManager#getDefaultDisplay() - android.view.Display#getSize (Docs): https://developer.android.com/reference/android/view/ Display#getSize(android.graphics.Point) - android.view.View.setSystemUiVisibility (Docs): https://developer.android.com/reference/android/view/ View#setSystemUiVisibility(int) - android.view.View.getSystemUiVisibility (Docs): https://developer.android.com/reference/android/view/ View#getSystemUiVisibility()
Warning Messages: - "'getter for fragmentManager: FragmentManager?' is deprecated Deprecated in Java" - "'requireFragmentManager(): FragmentManager' is deprecated. Deprecated in Java" - "'constructor FragmentPagerAdapter(FragmentManager)' is deprecated. Deprecated in Java" - "'show(FragmentManager!, String!): Unit' is deprecated. Deprecated in Java" These deprecated warnings are suppressed, that is, instead of being resolved, since a resolution would require a proper migration. You will also notice that I suppressed the deprecated warning both, on the file level and closer to the deprecation itself. In addition to that, you will notice that I suppressed the deprecated warning for other such warnings, like 'DialogFragment'. I did that because suppressing on the file level was necessary due to the 'android.app.FragmentManager' import that can't be suppressed any other way. But, when doing so, every deprecated warning is suppressed as well. At which point the deprecated information is lost. This way, adding first the '@Suppress ("DEPRECATION")' closer to source and then adding it on the file level makes sure that this information is not lost, at least for the existing code. For more info see: - androidx.fragment.app.Fragment.getFragmentManager (Docs): https://developer.android.com/reference/androidx/fragment/app/ Fragment#getFragmentManager() - androidx.fragment.app.Fragment#.requireFragmentManager (Docs): https://developer.android.com/reference/androidx/fragment/app/ Fragment#requireFragmentManager()
Warning Message: "'constructor Handler()' is deprecated.
Deprecated in Java"
Specifying the `Lopper` explicitly, using 'Looper.getMainLooper()' is
the recommended action to resolve this kind of deprecated warnings.
Explanation: "This constructor is deprecated. Implicitly choosing a
Looper during Handler construction can lead to bugs where operations are
silently lost (if the Handler is not expecting new tasks and quits),
crashes (if a handler is sometimes created on a thread without a Looper
active), or race conditions, where the thread a handler is associated
with is not what the author anticipated. Instead, use an Executor or
specify the Looper explicitly, using Looper#getMainLooper,
{link android.view.View#getHandler}, or similar. If the implicit thread
local behavior is required for compatibility, use
new Handler(Looper.myLooper()) to make it clear to readers."
Docs: https://developer.android.com/reference/android/os/
Handler#Handler()
Warning Message: "'setBoundsInParent(Rect!): Unit' is deprecated. Deprecated in Java" These deprecated warnings are suppressed, that is, instead of being resolved, since a resolution would require a proper migration. For more info see: - android.view.accessibility.AccessibilityNodeInfo.setBoundsInParent: https://developer.android.com/reference/android/view/accessibility/ AccessibilityNodeInfo#setBoundsInParent(android.graphics.Rect)
Warning Messages: - "'GET_SIGNATURES: Int' is deprecated. Deprecated in Java" - "'signatures: Array<(out) Signature!>!' is deprecated. Deprecated in Java" These deprecated warnings are suppressed, that is, instead of being resolved, since a resolution would require a proper migration. For more info see: - android.content.pm.PackageManager.GET_SIGNATURES (Docs): https://developer.android.com/reference/android/content/pm/ PackageManager#GET_SIGNATURES - android.content.pm.PackageInfo.signatures (Docs): https://developer.android.com/reference/android/content/pm/ PackageInfo#signatures
Warning Messages: "'markState(Lifecycle.State): Unit' is deprecated. Deprecated in Java" Replacing the deprecated 'markState(...)' with the 'currentState' related version is the recommended action to resolve this kind of deprecated warnings. For more info see: - androidx.lifecycle.LifecycleRegistry.markState (Docs): https://developer.android.com/reference/androidx/lifecycle/ LifecycleRegistry#markState(androidx.lifecycle.Lifecycle.State) - androidx.lifecycle.LifecycleRegistry.setCurrentState (Docs): https://developer.android.com/reference/androidx/lifecycle/ LifecycleRegistry#setCurrentState(androidx.lifecycle.Lifecycle.State)
Warning Messages: "'getActionMasked(MotionEvent!): Int' is deprecated. Deprecated in Java" Replacing the usage of 'MotionEventCompat' to get the action masked, by calling get action marked directly is the recommended action to resolve this kind of deprecated warnings. PS: It seems every method within 'MotionEventCompat' is now deprecated and pointing to using 'MotionEvent' directly instead as this will be removed in a future release. For more info see: - androidx.core.view.MotionEventCompat.getActionMasked (Docs): https://developer.android.com/reference/androidx/core/view/ MotionEventCompat#getActionMasked(android.view.MotionEvent)
After resolving some of the compile related deprecated warnings, some Detekt baseline related warnings needed to be removed and suppressed closer to source because the lines on those classes got changed. Also, a few new Detekt violations appeared, like the new 'LongMethod' violation on the 'MeFragment' class for the 'onActivityResult(...)' function. Within this commit, those got suppressed as well so that Detekt completes successfully without any new issues.
Contributor
|
|||||||||||
| 💡 Scan this QR code with your Android phone to download and install the APK directly on it. | ||
| App | Jetpack | |
| Build Flavor | Jalapeno | |
| Build Type | Debug | |
| Commit | 7811dd1 | |
Contributor
|
|||||||||||
| 💡 Scan this QR code with your Android phone to download and install the APK directly on it. | ||
| App | WordPress | |
| Build Flavor | Jalapeno | |
| Build Type | Debug | |
| Commit | 7811dd1 | |
This was referenced Oct 4, 2022
Contributor
Author
|
Thank you for reviewing and testing this PR @ovitrif , you rock! 🙇 ❤️ 🚀 |
3 tasks
Closed
3 tasks
12 tasks
12 tasks
18 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Parent: #17173
Partially Closes: #17181
This PR resolves one part of all
Deprecatedrelated warnings for theWordPressmodule, and in this part, the most generic ones and specific to the main source:Main Source (About
247)247warnings x'XYX' is deprecated. Deprecated in JavaWarnings Resolution List:
Warnings Suppression List:
Refactor List:
In addition to the above warning resolution list, the below
Detektwarnings got resolved as well, leaving Detekt'sbaseline.xmlfile 5 entries shorter:PS: @ovitrif I added you as the main reviewer, that is, in addition to @wordpress-mobile/apps-infrastructure team itself, but randomly, since I want someone from the WordPress Android team to primarily sign-off on that change. 🥇
FYI: I am going to randomly add more of you in those PRs that will follow, just so you become more aware of this change and how close we are on enabling allWarningsAsErrors by default everywhere. 🎉
To test:
WordPressandJetpackapps, and see if they are both working as expected.MySite,ReaderandNotificationtab labels are shown on the selected navigation item.MySite,ReaderandNotificationtabs to make sure that when selecting a new tab, theonNavigationItemSelected(...)function is called, while when re-selecting the existing tab, theonNavigationItemReselected(...)function is called.Postsscreen works as expected.Regression Notes
See the
targeted testingpart above, which is, within theTo testsection itself.See
To testsection above.N/A
PR submission checklist:
RELEASE-NOTES.txtif necessary.