-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Lint Warnings] Source Set: Main - Resolve All Warnings [Correctness
] - Part.1
#18245
[Lint Warnings] Source Set: Main - Resolve All Warnings [Correctness
] - Part.1
#18245
Conversation
Warning Message: "Use of LayoutInflater.from(getActivity()) detected. Consider using getLayoutInflater() instead" Explanation: "Using LayoutInflater.from(Context) can return a LayoutInflater that does not have the correct theme." ------------------------------------------------------------------------ The recommended use of 'getLayoutInflater()', instead of using the deprecated 'LayoutInflater.from(getActivity())' is causing a 'StackOverflowError' error. Thus, this error is suppress for 'NumberPickerDialog' (at least for the time being).
Warning Message: "Use of LayoutInflater.from(getActivity()) detected. Consider using getLayoutInflater() instead" Explanation: "Using LayoutInflater.from(Context) can return a LayoutInflater that does not have the correct theme." ------------------------------------------------------------------------ Using the recommended 'getLayoutInflater()', and on those specific cases via 'getActivity()', fix these warnings.
Warning Message: "WRITE_EXTERNAL_STORAGE no longer provides write access when targeting Android 11+, even when using 'requestLegacyExternalStorage'" Explanation: "Scoped storage is enforced on Android 10+ (or Android 11+ if using requestLegacyExternalStorage). In particular, WRITE_EXTERNAL_STORAGE will no longer provide write access to all files; it will provide the equivalent of READ_EXTERNAL_STORAGE instead." ------------------------------------------------------------------------ This warning is already addressed and will be fixed as part of the ongoing Android 13 media permissions work (see PR below): PR: #18183
Warning Message: "Calling `setType` after calling `setData` will clear the data: Call `setDataAndType` instead?" Explanation: "Intent provides the following APIs: setData(Uri) and setType(String). Unfortunately, setting one clears the other. If you want to set both, you should call setDataAndType(Uri, String) instead." ------------------------------------------------------------------------ This 78c2ea7 introduced this functionality. Testing without the 'calIntent.data = Events.CONTENT_URI' still works as expected. Thus, indeed it seems that the 'data' got cleared by setting the 'type' afterwards, thus the code, if kept as is, although still functioning, becomes misleading and worse, the 'data' related 'Events.CONTENT_URI' information ends-up being missing from the intent that starts the external calendar activity. From the looks of it, it seems that the author's intentions were to use both, 'data' and 'type'. As such, using the recommended 'setDataAndType(...)' fixes this warning. ------------------------------------------------------------------------ FOr more info see: - Calendar provider overview (Doc): https://developer.android.com/guide/topics/providers/calendar-provider - Use an intent to insert an event (Doc): https://developer.android.com/guide/topics/providers/calendar-provider #intent-insert
Warning Messages: - "The locale folder "'he'" should be called "'iw'" instead; see the 'java.util.Locale' documentation" - "The locale folder "'id'" should be called "'in'" instead; see the 'java.util.Locale' documentation" Explanation: "From the java.util.Locale documentation: "Note that Java uses several deprecated two-letter codes. The Hebrew ("he") language code is rewritten as "iw", Indonesian ("id") as "in", and Yiddish ("yi") as "ji". This rewriting happens even if you construct your own Locale object, not just for instances returned by the various lookup methods. Because of this, if you add your localized resources in for example values-he they will not be used, since the system will look for values-iw instead. To work around this, place your resources in a values folder using the deprecated language code instead." ------------------------------------------------------------------------ This Lint warning is moved within lint config and removed from Lint's baseline because in order to resolve this warning a proper release management localization solution should be set-up for both, the WordPress and Jetpack apps. PS: The previous such Jetpack related c272690 commit description was misleading (describing this was already properly done on WordPress). Related: Lint Warnings - Resolve 'LocaleFolder' - #18226
Warning Message: "Redundant 'field' used for Dagger qualifier annotation." Explanation: "It's redundant to use 'field:' site-targets for qualifier annotations." ------------------------------------------------------------------------ This was probably an oversight while this efb4b8f commit was developed. Removing the redundant 'field' site-target fixes these warnings.
Instead of using an arbitrary 'IO_THREAD' string value, it is better to depend on using the 'IO_THREAD' constant from within the 'ThreadModule' file, which anyway points to that same 'IO_THREAD' string value.
Warning Message: "Replace the <fragment> tag with FragmentContainerView." Explanation: "FragmentContainerView replaces the <fragment> tag as the preferred way of adding fragments via XML. Unlike the <fragment> tag, FragmentContainerView uses a normal FragmentTransaction under the hood to add the initial fragment, allowing further FragmentTransaction operations on the FragmentContainerView and providing a consistent timing for lifecycle events." ------------------------------------------------------------------------ These warnings are suppressed on those files because the app crashes otherwise with a 'ClassCastException' exception (see an example crash on 'AccountSettingsFragment' below): ------------------------------------------------------------------------ Caused by: java.lang.ClassCastException: org.wordpress.android.ui.prefs.accountsettings.AccountSettingsFragment cannot be cast to androidx.fragment.app.Fragment ------------------------------------------------------------------------
Warning Message: "Replace the <fragment> tag with FragmentContainerView." Explanation: "FragmentContainerView replaces the <fragment> tag as the preferred way of adding fragments via XML. Unlike the <fragment> tag, FragmentContainerView uses a normal FragmentTransaction under the hood to add the initial fragment, allowing further FragmentTransaction operations on the FragmentContainerView and providing a consistent timing for lifecycle events." ------------------------------------------------------------------------ These warnings are suppressed on those files because the app crashes otherwise with a 'UninitializedPropertyAccessException' exception (see below): ------------------------------------------------------------------------ kotlin.UninitializedPropertyAccessException: lateinit property widgetType has not been initialized ------------------------------------------------------------------------
Warning Message: "Replace the <fragment> tag with FragmentContainerView." Explanation: "FragmentContainerView replaces the <fragment> tag as the preferred way of adding fragments via XML. Unlike the <fragment> tag, FragmentContainerView uses a normal FragmentTransaction under the hood to add the initial fragment, allowing further FragmentTransaction operations on the FragmentContainerView and providing a consistent timing for lifecycle events." ------------------------------------------------------------------------ Using the recommended '<androidx.fragment.app.FragmentContainerView>' fix these warnings.
📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
|
📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
|
Warning Message: "Use of LayoutInflater.from(getActivity()) detected. Consider using getLayoutInflater() instead" Explanation: "Using LayoutInflater.from(Context) can return a LayoutInflater that does not have the correct theme." ------------------------------------------------------------------------ Using the recommended 'getLayoutInflater()', and in this specific case via 'getActivity()', fixes this warning too. FYI: I previously suppressed it because I incorrectly used 'getLayoutInflater()' directly and not using 'getActivity()' first, like: 'getActivity().getLayoutInflater()'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are well-explained changes. I have checked them all. LGTM! Great Job! 👍🏻
I have tested all your written test cases in both WP and JP, and they have all passed. 🟢
Although I have left a comment, I am not merging but approving it because the issue will be resolved after syncing with the trunk
.
Maybe that needs to be corrected so the first one become a more generic Views title and much that of the views layout file.
It makes sense to me. We can open an issue for it.
Awesome, thank you so much for reviewing and testing these changes @irfano , you rock! 🙇 ❤️ 🚀
Yes, your comment is spot-on and I was waiting on it to happen, on way or another, depending on which PR would be merged first, this one or the targetSdkVersion-to-33 one, thanks for taking the time to call that off! 💯 |
Generated by 🚫 dangerJS |
Parent #18162
Partially Closes #18193
This PR resolves the 1st part of
correctness
Lint related warnings for theMain
source set:Reconfigure Lint (Ignore):
Warnings Resolution List:
Warnings Suppression List:
Refactor List:
PS: @irfano I added you as the main reviewer, randomly, since I just wanted someone from the WordPress team to be aware of and sign-off on that change for WPAndroid. I also added the @wordpress-mobile/apps-infrastructure team, but this in done only for monitoring purposes, as such, I am not expecting any active review from that team. Thus, feel free to merge this PR if you deem so.
To test:
Warnings Resolution List (✅):
[
UseGetLayoutInflater
]1. Number Picker Dialog [NumberPickerDialog.java]
My Site
tab ->MENU
sub-tab ->Side Settings
screen.Post per page
option and click on it.2. Post Settings Input Dialog [PostSettingsInputDialogFragment.java]
Posts
screen -> Find a post and click on it ->Post settings
screen.Password
option and click on it.3. Text Input Dialog [TextInputDialogFragment.java]
Me
screen ->My Profile
screen.First name
option and click on it.[
IntentReset
]1. Publish Settings Bottom Sheet [PublishSettingsFragment.kt]
Posts
screen -> Create a new post -> Click onPUBLISH
button.Publish Date
option and click on it.Date and Time
option and click on it.Notification
andAdd to calendar
options will appear.Add to calendar
option and click on it.Calendar
app and an draft calendar event is being createdon your behalf. Verify that the calendar title, description and dates are correct. Click on
Save
to create the calendar event. Verify that the calendar event has been created and is as expected.
[
FragmentTagUsage
]1. Edit Image Screen [activity_edit_image.xml]
Blogs
and add a newblog
post.image
block.image
block.media options
of this image (top right) and then clickedit
.Edit Image
screen is shown and functioning as expected.2. My Profile Settings Screen [app_settings_activity.xml]
Me
screen ->My Profile
settings screen.My Profile
settings screen is shown and functioning as expected.3. Debug Settings Screen [debug_settings_activity.xml]
Me
screen ->App Settings
screen ->Debug Settings
screen.Debug Settings
screen is shown and functioning as expected.4. Categories Setting Screen [site_settings_categories_list_activity.xml]
My Site
tab ->MENU
sub-tab ->Site Settings
screen.Writing
section in the middle and click on itsCategories
option.Categories
setting screen is shown and functioning as expected.5. Insights Management Screen [insights_management_activity.xml]
My Site
tab ->MENU
sub-tab ->Stats
screen.Add new stats card
option and click on it.Add New Card
stats setting screen is shown and functioning as expected.6. Plans Screen [plans_activity.xml]
ℹ️ This my site menu option is only shown conditionally.
My Site
tab ->MENU
sub-tab ->Plans
screen.Plans
screen is shown and functioning as expected.7. Activity Log Screen [activity_log_list_activity.xml]
My Site
tab ->MENU
sub-tab ->Activity Log
screen.Activity Log
screen is shown and functioning as expected.8. Backup Download Screen [backup_download_activity.xml]
My Site
tab ->MENU
sub-tab ->Backup
screen.Download Backup
screen is shown and functioning as expected.9. Restore Screen [restore_activity.xml]
My Site
tab ->MENU
sub-tab ->Backup
screen.Restore
screen is shown and functioning as expected.10. Scan Screen [scan_activity.xml]
ℹ️ This my site menu option is only shown conditionally.
My Site
tab ->MENU
sub-tab ->Scan
screen.Scan
screen is shown and functioning as expected.11. Scan History Screen [scan_history_activity.xml]
ℹ️ This my site menu option is only shown conditionally.
My Site
tab ->MENU
sub-tab ->Scan
screen.Scan History
screen is shown and functioning as expected.12. Threat Details Screen [scan_history_activity.xml]
ℹ️ You would need to add a threat to your side so that after you trigger 'Scan now' on your side,
then let it complete, it will finally show some threats on your site.
My Site
tab ->MENU
sub-tab ->Scan
screen.Thread found
list and click on it.Threat Details
screen is shown and functioning as expected.13. Set Parent Screen [pages_parent_activity.xml]
Pages
screen and set a parent page for a page (page options).Set Parent
screen is shown and functioning as expected.14. Follow Topics Screen [reader_interests_activity.xml]
Reader
tab ->DISCOVER
sub-tab.Follow topics
screen is shown and functioning as expected.15. At A Glance Widget Screen [stats_minified_widget_configure_activity.xml]
At a glance
widget to your home screen.At a glance
widget screen is shown and functioning as expected.Warnings Suppression List (❌):
[
FragmentTagUsage
]1. Account Settings Screen [account_settings_activity.xml]
❌ Exception:
ClassCastException
Me
screen ->My Profile
screen.Account Settings
screen is shown and functioning as expected.2. App Settings Screen [app_settings_activity.xml]
❌ Exception:
ClassCastException
Me
screen ->App Settings
screen.App Settings
screen is shown and functioning as expected.3. Jetpack Security Settings Screen [fragment_jetpack_security_settings.xml]
❌ Exception:
ClassCastException
ℹ️ It seems that this flow has been migrated into the
Site Settings
screen and itsJetpack Settings
section at the bottom. Thus, it is hard to be tested and most importantly maybe worth removing at some point due to it ending-up becoming dead code.My Site
tab ->MENU
sub-tab ->Jetpack Settings
screen.App Settings
screen is shown and functioning as expected.4. All Time + Today + Views + Views This Week Widget Screens [stats_xyz_widget_configure_activity.xml]
❌ Exception:
UninitializedPropertyAccessException
ℹ️ The 'xyz' part of the file name is either
all_time
,today
,views
orweek_views
.❓️ The widget title for
views
orweek_views
is always the same, theViews this week
one. Maybe that needs to be corrected so the first one become a more genericViews
title and much that of theviews
layout file.All-time
,Today
,Views this week
orViews this week
widget to your home screen.All-time
,Today
,Views this week
orViews this week
widget screen areshown and functioning as expected.
Regression Notes
Potential unintended areas of impact
PublishSettingsFragment
and itsAddToCalendar
functionality.LayoutInflater.from(getActivity())
tag got replaced with theactivity().getLayoutInflater()
tag.<fragment>
tag got replaced with the<androidx.fragment.app.FragmentContainerView>
tag.What I did to test those areas of impact (or what existing automated tests I relied on)
To test
section above.What automated tests I added (or what prevented me from doing so)
PR submission checklist:
RELEASE-NOTES.txt
if necessary.