From 7899a655ea0d31cb78d691707fcc54a6d492e8ab Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 17 Aug 2023 17:12:35 +0300 Subject: [PATCH 01/29] Analysis: Add missing n-a to sdk override methods for editor abstract FYI: 'n-a' stands for 'nullability annotations'. --- .../wordpress/android/editor/EditorFragmentAbstract.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libs/editor/src/main/java/org/wordpress/android/editor/EditorFragmentAbstract.java b/libs/editor/src/main/java/org/wordpress/android/editor/EditorFragmentAbstract.java index 403cb893bc0e..3d8242338a63 100644 --- a/libs/editor/src/main/java/org/wordpress/android/editor/EditorFragmentAbstract.java +++ b/libs/editor/src/main/java/org/wordpress/android/editor/EditorFragmentAbstract.java @@ -7,6 +7,7 @@ import android.view.DragEvent; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.core.util.Consumer; import androidx.core.util.Pair; import androidx.fragment.app.Fragment; @@ -108,7 +109,7 @@ public static MediaType fromString(String value) { protected HashMap mCustomHttpHeaders; @Override - public void onAttach(Activity activity) { + public void onAttach(@NonNull Activity activity) { super.onAttach(activity); try { mEditorFragmentListener = (EditorFragmentListener) activity; @@ -118,7 +119,7 @@ public void onAttach(Activity activity) { } @Override - public void onSaveInstanceState(Bundle outState) { + public void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); outState.putBoolean(FEATURED_IMAGE_SUPPORT_KEY, mFeaturedImageSupported); @@ -126,7 +127,7 @@ public void onSaveInstanceState(Bundle outState) { } @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { From bf3811e121fb5f47d6f857034daee7db0262ff0a Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 17 Aug 2023 17:33:40 +0300 Subject: [PATCH 02/29] Analysis: Add missing n-a to sdk override methods for aztec editor FYI: 'n-a' stands for 'nullability annotations'. --- .../android/editor/AztecEditorFragment.java | 85 ++++++++++++------- 1 file changed, 53 insertions(+), 32 deletions(-) diff --git a/libs/editor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java b/libs/editor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java index 51691cc7124d..d440500d568b 100644 --- a/libs/editor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java +++ b/libs/editor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java @@ -45,6 +45,7 @@ import android.widget.Toast; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; @@ -219,7 +220,7 @@ public static AztecEditorFragment newInstance(String title, String content, bool } @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ProfilingUtils.start("Visual Editor Startup"); @@ -230,8 +231,10 @@ public void onCreate(Bundle savedInstanceState) { } } + @Nullable @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_aztec_editor, container, false); mFragmentView = view; @@ -269,15 +272,15 @@ public void onImeBack() { mTitle.addTextChangedListener(new TextWatcher() { @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { + public void beforeTextChanged(@NonNull CharSequence s, int start, int count, int after) { } @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { + public void onTextChanged(@NonNull CharSequence s, int start, int before, int count) { } @Override - public void afterTextChanged(Editable s) { + public void afterTextChanged(@NonNull Editable s) { for (int i = s.length(); i > 0; i--) { if (s.subSequence(i - 1, i).toString().equals("\n")) { s.replace(i - 1, i, " "); @@ -307,7 +310,7 @@ public void afterTextChanged(Editable s) { mTitle.setOnFocusChangeListener( new View.OnFocusChangeListener() { @Override - public void onFocusChange(View view, boolean hasFocus) { + public void onFocusChange(@NonNull View v, boolean hasFocus) { mFormattingToolbar.enableFormatButtons(!hasFocus); } } @@ -389,7 +392,8 @@ public void onClick(View view) { return view; } - @Override public void onDestroyView() { + @Override + public void onDestroyView() { super.onDestroyView(); mContent.getContentChangeWatcher().unregisterObserver(this); } @@ -439,7 +443,7 @@ public void onResume() { } @Override - public void onAttach(Activity activity) { + public void onAttach(@NonNull Activity activity) { super.onAttach(activity); try { @@ -450,17 +454,17 @@ public void onAttach(Activity activity) { } @Override - public void onSaveInstanceState(Bundle outState) { + public void onSaveInstanceState(@NonNull Bundle outState) { outState.putParcelable(ATTR_TAPPED_MEDIA_PREDICATE, mTappedMediaPredicate); } @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) { inflater.inflate(R.menu.menu_aztec, menu); } @Override - public void onPrepareOptionsMenu(Menu menu) { + public void onPrepareOptionsMenu(@NonNull Menu menu) { // TODO: disable undo/redo in media mode boolean canRedo = mContent.history.redoValid(); boolean canUndo = mContent.history.undoValid(); @@ -502,7 +506,7 @@ public boolean isHistoryEnabled() { } @Override - public boolean onOptionsItemSelected(MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { if (item.getItemId() == R.id.undo) { if (mContent.getVisibility() == View.VISIBLE) { mContent.undo(); @@ -796,14 +800,15 @@ private void checkForFailedUploadAndSwitchToHtmlMode() { new MaterialAlertDialogBuilder(getActivity()) .setMessage(R.string.editor_failed_uploads_switch_html) .setPositiveButton(R.string.editor_remove_failed_uploads, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { + @Override + public void onClick(@Nullable DialogInterface dialog, int which) { // Clear failed uploads and switch to HTML mode removeAllFailedMediaUploads(); toggleHtmlMode(); } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override - public void onClick(DialogInterface dialog, int which) { + public void onClick(@Nullable DialogInterface dialog, int which) { // nothing special to do } }) @@ -1080,7 +1085,8 @@ private void replaceDrawable(Drawable newDrawable) { mContent.refreshText(); } - @Override public void onImageFailed() { + @Override + public void onImageFailed() { if (!isAdded()) { // the fragment is detached return; @@ -1088,7 +1094,8 @@ private void replaceDrawable(Drawable newDrawable) { replaceDrawable(getLoadingMediaErrorPlaceholder(null)); } - @Override public void onImageLoaded(Drawable drawable) { + @Override + public void onImageLoaded(Drawable drawable) { if (!isAdded()) { // the fragment is detached return; @@ -1106,7 +1113,8 @@ private void replaceDrawable(Drawable newDrawable) { replaceDrawable(drawable); } - @Override public void onImageLoading(Drawable drawable) { + @Override + public void onImageLoading(Drawable drawable) { } }, maxMediaSize); mActionStartedAt = System.currentTimeMillis(); @@ -1158,7 +1166,8 @@ private void replaceDrawable(Drawable newDrawable) { } } - @Override public void appendMediaFiles(Map mediaList) { + @Override + public void appendMediaFiles(Map mediaList) { for (Map.Entry pair : mediaList.entrySet()) { appendMediaFile(pair.getValue(), pair.getKey(), null); } @@ -1221,7 +1230,8 @@ public void removeMedia(String mediaId) { mContent.removeMedia(MediaPredicate.getLocalMediaIdPredicate(mediaId)); } - @Override public void mediaSelectionCancelled() { + @Override + public void mediaSelectionCancelled() { // noop implementation for shared interface with block editor } @@ -1341,7 +1351,7 @@ public boolean matches(@NonNull Attributes attrs) { return attrs.getIndex(mAttributeName) > -1 && attrs.getValue(mAttributeName).equals(mId); } - protected MediaPredicate(Parcel in) { + protected MediaPredicate(@NonNull Parcel in) { mId = in.readString(); mAttributeName = in.readString(); } @@ -1359,11 +1369,13 @@ public void writeToParcel(Parcel dest, int flags) { @SuppressWarnings("unused") public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { + @NonNull @Override - public MediaPredicate createFromParcel(Parcel in) { + public MediaPredicate createFromParcel(@NonNull Parcel in) { return new MediaPredicate(in); } + @NonNull @Override public MediaPredicate[] newArray(int size) { return new MediaPredicate[size]; @@ -1447,7 +1459,7 @@ public void onGalleryMediaUploadSucceeded(final long galleryId, long remoteMedia } @Override - public void onConfigurationChanged(Configuration newConfig) { + public void onConfigurationChanged(@NonNull Configuration newConfig) { super.onConfigurationChanged(newConfig); // Toggle action bar auto-hiding for the new orientation if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE @@ -1461,7 +1473,7 @@ public void onConfigurationChanged(Configuration newConfig) { } @Override - public boolean onTouch(View view, MotionEvent event) { + public boolean onTouch(@NonNull View v, @NonNull MotionEvent event) { // In landscape mode, if the title or content view has received a touch event, the keyboard will be // displayed and the action bar should hide if (event.getAction() == MotionEvent.ACTION_UP @@ -1531,7 +1543,7 @@ private boolean isSupported(ClipDescription clipDescription, List mimeTy } @Override - public boolean onDrag(View view, DragEvent dragEvent) { + public boolean onDrag(@NonNull View v, @NonNull DragEvent dragEvent) { switch (dragEvent.getAction()) { case DragEvent.ACTION_DRAG_STARTED: return isSupported(dragEvent.getClipDescription(), DRAGNDROP_SUPPORTED_MIMETYPES_TEXT) @@ -1677,13 +1689,16 @@ public void showNotice(String message) { ToastUtils.showToast(getActivity(), message).show(); } - @Override public void showEditorHelp() { + @Override + public void showEditorHelp() { } - @Override public void onUndoPressed() { + @Override + public void onUndoPressed() { } - @Override public void onRedoPressed() { + @Override + public void onRedoPressed() { } private void onMediaTapped(@NonNull final AztecAttributes attrs, int naturalWidth, int naturalHeight, @@ -1724,7 +1739,8 @@ private void onMediaTapped(@NonNull final AztecAttributes attrs, int naturalWidt builder.setTitle(getString(R.string.stop_upload_dialog_title)); builder.setPositiveButton(R.string.stop_upload_dialog_button_yes, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { + @Override + public void onClick(@Nullable DialogInterface dialog, int which) { if (mUploadingMediaProgressMax.containsKey(localMediaId)) { mEditorFragmentListener.onMediaUploadCancelClicked(localMediaId); @@ -1740,13 +1756,18 @@ public void onClick(DialogInterface dialog, int id) { ToastUtils.showToast(getActivity(), R.string.upload_finished_toast).show(); } - dialog.dismiss(); + if (dialog != null) { + dialog.dismiss(); + } } }); builder.setNegativeButton(R.string.stop_upload_dialog_button_no, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - dialog.dismiss(); + @Override + public void onClick(@Nullable DialogInterface dialog, int which) { + if (dialog != null) { + dialog.dismiss(); + } } }); @@ -1865,7 +1886,7 @@ public void onClick(DialogInterface dialog, int id) { } @Override - public void onActivityResult(int requestCode, int resultCode, Intent data) { + public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == EDITOR_MEDIA_SETTINGS) { From 794a9ac7a484f82940ca35cdfbb474a88ff220ea Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 17 Aug 2023 17:54:48 +0300 Subject: [PATCH 03/29] Analysis: Add missing n-a to sdk override methods for gutenberg editor FYI: 'n-a' stands for 'nullability annotations'. --- .../gutenberg/GutenbergEditorFragment.java | 163 ++++++++++++------ 1 file changed, 108 insertions(+), 55 deletions(-) diff --git a/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java b/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java index 89dfe84b9192..7823e4d7278e 100644 --- a/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java +++ b/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergEditorFragment.java @@ -195,7 +195,7 @@ private GutenbergContainerFragment getGutenbergContainerFragment() { @SuppressWarnings("unchecked") @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getGutenbergContainerFragment() == null) { @@ -227,8 +227,10 @@ public void onCreate(Bundle savedInstanceState) { } } + @Nullable @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_gutenberg_editor, container, false); initializeSavingProgressDialog(); @@ -241,7 +243,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa ViewGroup gutenbergContainer = view.findViewById(R.id.gutenberg_container); getGutenbergContainerFragment().attachToContainer(gutenbergContainer, new OnMediaLibraryButtonListener() { - @Override public void onMediaLibraryImageButtonClicked(boolean allowMultipleSelection) { + @Override + public void onMediaLibraryImageButtonClicked(boolean allowMultipleSelection) { mEditorFragmentListener.onTrackableEvent(TrackableEvent.MEDIA_BUTTON_TAPPED); mEditorFragmentListener.onAddMediaImageClicked(allowMultipleSelection); } @@ -258,12 +261,14 @@ public void onMediaLibraryMediaButtonClicked(boolean allowMultipleSelection) { mEditorFragmentListener.onAddLibraryMediaClicked(allowMultipleSelection); } - @Override public void onMediaLibraryFileButtonClicked(boolean allowMultipleSelection) { + @Override + public void onMediaLibraryFileButtonClicked(boolean allowMultipleSelection) { mEditorFragmentListener.onTrackableEvent(TrackableEvent.MEDIA_BUTTON_TAPPED); mEditorFragmentListener.onAddLibraryFileClicked(allowMultipleSelection); } - @Override public void onMediaLibraryAudioButtonClicked(boolean allowMultipleSelection) { + @Override + public void onMediaLibraryAudioButtonClicked(boolean allowMultipleSelection) { mEditorFragmentListener.onTrackableEvent(TrackableEvent.MEDIA_BUTTON_TAPPED); mEditorFragmentListener.onAddLibraryAudioFileClicked(allowMultipleSelection); } @@ -328,7 +333,8 @@ public ArrayList onGetOtherMediaFileOptions() { return otherMediaFileOptions; } - @Override public ArrayList onGetOtherMediaAudioFileOptions() { + @Override + public ArrayList onGetOtherMediaAudioFileOptions() { return initOtherMediaAudioFileOptions(); } @@ -361,7 +367,8 @@ public void onQueryCurrentProgressForUploadingMedia() { } }, new OnReattachMediaSavingQueryListener() { - @Override public void onQueryCurrentProgressForSavingMedia() { + @Override + public void onQueryCurrentProgressForSavingMedia() { // TODO: probably go through mFailedMediaIds, and see if any block in the post content // has these mediaFIleIds. If there's a match, mark such a block in FAILED state. updateFailedMediaState(); @@ -441,7 +448,8 @@ public void gutenbergDidRequestUnsupportedBlockFallback(UnsupportedBlock unsuppo } }, new OnGutenbergDidRequestEmbedFullscreenPreviewListener() { - @Override public void gutenbergDidRequestEmbedFullscreenPreview(String html, String title) { + @Override + public void gutenbergDidRequestEmbedFullscreenPreview(String html, String title) { openGutenbergEmbedWebViewActivity(html, title); } }, @@ -453,16 +461,19 @@ public void gutenbergDidSendButtonPressedAction(String buttonType) { }, new ShowSuggestionsUtil() { - @Override public void showUserSuggestions(Consumer onResult) { + @Override + public void showUserSuggestions(Consumer onResult) { mEditorFragmentListener.showUserSuggestions(onResult); } - @Override public void showXpostSuggestions(Consumer onResult) { + @Override + public void showXpostSuggestions(Consumer onResult) { mEditorFragmentListener.showXpostSuggestions(onResult); } }, new OnMediaFilesCollectionBasedBlockEditorListener() { - @Override public void onRequestMediaFilesEditorLoad(ArrayList mediaFiles, String blockId) { + @Override + public void onRequestMediaFilesEditorLoad(ArrayList mediaFiles, String blockId) { // let's first calculate the hash on this mediaFiles array, this will let us // identify the block later when we need to replace it as we come back from the Story // composer @@ -472,7 +483,8 @@ public void gutenbergDidSendButtonPressedAction(String buttonType) { mEditorFragmentListener.onStoryComposerLoadRequested(mediaFiles, blockId); } - @Override public void onCancelUploadForMediaCollection(ArrayList mediaFiles) { + @Override + public void onCancelUploadForMediaCollection(ArrayList mediaFiles) { if (getActivity() != null) { getActivity().runOnUiThread(() -> { showCancelMediaCollectionUploadDialog(mediaFiles); @@ -480,7 +492,8 @@ public void gutenbergDidSendButtonPressedAction(String buttonType) { } } - @Override public void onRetryUploadForMediaCollection(ArrayList mediaFiles) { + @Override + public void onRetryUploadForMediaCollection(ArrayList mediaFiles) { if (getActivity() != null) { getActivity().runOnUiThread(() -> { showRetryMediaCollectionUploadDialog(mediaFiles); @@ -488,7 +501,8 @@ public void gutenbergDidSendButtonPressedAction(String buttonType) { } } - @Override public void onCancelSaveForMediaCollection(ArrayList mediaFiles) { + @Override + public void onCancelSaveForMediaCollection(ArrayList mediaFiles) { if (getActivity() != null) { getActivity().runOnUiThread(() -> { showCancelMediaCollectionSaveDialog(mediaFiles); @@ -496,7 +510,8 @@ public void gutenbergDidSendButtonPressedAction(String buttonType) { } } - @Override public void onMediaFilesBlockReplaceSync(ArrayList mediaFiles, String blockId) { + @Override + public void onMediaFilesBlockReplaceSync(ArrayList mediaFiles, String blockId) { if (mStoryBlockReplacedSignalWait) { // in case we were expecting a fresh block replacement sync signal, let the fragment // listener know so it can process all of the pending block save / update / upload events @@ -773,7 +788,8 @@ private ArrayList initOtherMediaFileOptions(String mediaOptionId) { return otherMediaOptions; } - @Override public void onResume() { + @Override + public void onResume() { super.onResume(); setEditorProgressBarVisibility(!mEditorDidMount); @@ -861,7 +877,8 @@ private void showCancelMediaUploadDialog(final int localMediaId) { builder.setTitle(getString(R.string.stop_upload_dialog_title)); builder.setPositiveButton(R.string.stop_upload_dialog_button_yes, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { + @Override + public void onClick(@Nullable DialogInterface dialog, int which) { if (mUploadingMediaProgressMax.containsKey(String.valueOf(localMediaId))) { mEditorFragmentListener.onMediaUploadCancelClicked(String.valueOf(localMediaId)); // remove from editor @@ -872,13 +889,18 @@ public void onClick(DialogInterface dialog, int id) { } else { ToastUtils.showToast(getActivity(), R.string.upload_finished_toast).show(); } - dialog.dismiss(); + if (dialog != null) { + dialog.dismiss(); + } } }); builder.setNegativeButton(R.string.stop_upload_dialog_button_no, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - dialog.dismiss(); + @Override + public void onClick(@Nullable DialogInterface dialog, int which) { + if (dialog != null) { + dialog.dismiss(); + } } }); @@ -897,15 +919,21 @@ private void showRetryMediaUploadDialog(final int mediaId) { } builder.setPositiveButton(R.string.retry_failed_upload_yes, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - dialog.dismiss(); + @Override + public void onClick(@Nullable DialogInterface dialog, int which) { + if (dialog != null) { + dialog.dismiss(); + } mEditorFragmentListener.onMediaRetryAllClicked(mFailedMediaIds); } }); builder.setNegativeButton(R.string.retry_failed_upload_remove, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - dialog.dismiss(); + @Override + public void onClick(@Nullable DialogInterface dialog, int which) { + if (dialog != null) { + dialog.dismiss(); + } mEditorFragmentListener.onMediaDeleted(String.valueOf(mediaId)); mFailedMediaIds.remove(String.valueOf(mediaId)); getGutenbergContainerFragment().clearMediaFileURL(mediaId); @@ -953,8 +981,9 @@ private void showCancelMediaCollectionUploadDialog(ArrayList mediaFiles) builder.setTitle(getString(R.string.stop_upload_dialog_title)); builder.setPositiveButton(R.string.stop_upload_dialog_button_yes, new DialogInterface.OnClickListener() { + @Override @SuppressWarnings("unchecked") - public void onClick(DialogInterface dialog, int id) { + public void onClick(@Nullable DialogInterface dialog, int which) { mEditorFragmentListener.onCancelUploadForMediaCollection(mediaFiles); // now signal Gutenberg upload failed, and remove the mediaIds from our tracking map for (Object mediaFile : mediaFiles) { @@ -966,13 +995,18 @@ public void onClick(DialogInterface dialog, int id) { getGutenbergContainerFragment().mediaFileUploadFailed(localMediaId); mUploadingMediaProgressMax.remove(localMediaId); } - dialog.dismiss(); + if (dialog != null) { + dialog.dismiss(); + } } }); builder.setNegativeButton(R.string.stop_upload_dialog_button_no, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - dialog.dismiss(); + @Override + public void onClick(@Nullable DialogInterface dialog, int which) { + if (dialog != null) { + dialog.dismiss(); + } } }); @@ -987,15 +1021,21 @@ private void showRetryMediaCollectionUploadDialog(ArrayList mediaFiles) builder.setTitle(getString(R.string.retry_failed_upload_title)); builder.setPositiveButton(R.string.retry_failed_upload_yes, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { + @Override + public void onClick(@Nullable DialogInterface dialog, int which) { mEditorFragmentListener.onRetryUploadForMediaCollection(mediaFiles); - dialog.dismiss(); + if (dialog != null) { + dialog.dismiss(); + } } }); builder.setNegativeButton(R.string.dialog_button_cancel, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - dialog.dismiss(); + @Override + public void onClick(@Nullable DialogInterface dialog, int which) { + if (dialog != null) { + dialog.dismiss(); + } } }); @@ -1011,8 +1051,11 @@ private void showCancelMediaCollectionSaveDialog(ArrayList mediaFiles) { builder.setMessage(getString(R.string.stop_save_dialog_message)); builder.setPositiveButton(R.string.stop_save_dialog_ok_button, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - dialog.dismiss(); + @Override + public void onClick(@Nullable DialogInterface dialog, int which) { + if (dialog != null) { + dialog.dismiss(); + } } }); @@ -1026,7 +1069,7 @@ private void showImplicitKeyboard() { } @Override - public void onAttach(Activity activity) { + public void onAttach(@NonNull Activity activity) { super.onAttach(activity); try { @@ -1049,7 +1092,7 @@ public void onAttach(Activity activity) { } @Override - public void onSaveInstanceState(Bundle outState) { + public void onSaveInstanceState(@NonNull Bundle outState) { outState.putBoolean(KEY_HTML_MODE_ENABLED, mHtmlModeEnabled); outState.putBoolean(KEY_EDITOR_DID_MOUNT, mEditorDidMount); outState.putString(ARG_STORY_BLOCK_EXTERNALLY_EDITED_ORIGINAL_HASH, mExternallyEditedBlockOriginalHash); @@ -1058,22 +1101,20 @@ public void onSaveInstanceState(Bundle outState) { } @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) { inflater.inflate(R.menu.menu_gutenberg, menu); } @Override - public void onPrepareOptionsMenu(Menu menu) { - if (menu != null) { - MenuItem debugMenuItem = menu.findItem(R.id.debugmenu); - debugMenuItem.setVisible(BuildConfig.DEBUG); - } + public void onPrepareOptionsMenu(@NonNull Menu menu) { + MenuItem debugMenuItem = menu.findItem(R.id.debugmenu); + debugMenuItem.setVisible(BuildConfig.DEBUG); super.onPrepareOptionsMenu(menu); } @Override - public boolean onOptionsItemSelected(MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { if (item.getItemId() == R.id.debugmenu) { getGutenbergContainerFragment().showDevOptionsDialog(); return true; @@ -1209,7 +1250,8 @@ public Pair getTitleAndContent(CharSequence original throw new EditorFragmentNotAddedException(); } return getGutenbergContainerFragment().getTitleAndContent(originalContent, new OnGetContentInterrupted() { - @Override public void onGetContentInterrupted(InterruptedException ie) { + @Override + public void onGetContentInterrupted(InterruptedException ie) { AppLog.e(T.EDITOR, ie); Thread.currentThread().interrupt(); } @@ -1237,7 +1279,8 @@ public CharSequence getContent(CharSequence originalContent) throws EditorFragme throw new EditorFragmentNotAddedException(); } return getGutenbergContainerFragment().getContent(originalContent, new OnGetContentInterrupted() { - @Override public void onGetContentInterrupted(InterruptedException ie) { + @Override + public void onGetContentInterrupted(InterruptedException ie) { AppLog.e(T.EDITOR, ie); Thread.currentThread().interrupt(); } @@ -1408,7 +1451,8 @@ public void onDestroy() { super.onDestroy(); } - @Override public void mediaSelectionCancelled() { + @Override + public void mediaSelectionCancelled() { getGutenbergContainerFragment().mediaSelectionCancelled(); } @@ -1473,28 +1517,33 @@ public void onEditorThemeUpdated(Bundle editorTheme) { getGutenbergContainerFragment().updateTheme(editorTheme); } - @Override public void onMediaSaveReattached(String localId, float currentProgress) { + @Override + public void onMediaSaveReattached(String localId, float currentProgress) { mUploadingMediaProgressMax.put(localId, currentProgress); getGutenbergContainerFragment().mediaFileSaveProgress(localId, currentProgress); } - @Override public void onMediaSaveSucceeded(String localId, String mediaUrl) { + @Override + public void onMediaSaveSucceeded(String localId, String mediaUrl) { mUploadingMediaProgressMax.remove(localId); getGutenbergContainerFragment().mediaFileSaveSucceeded(localId, mediaUrl); } - @Override public void onMediaSaveProgress(String localId, float progress) { + @Override + public void onMediaSaveProgress(String localId, float progress) { mUploadingMediaProgressMax.put(localId, progress); getGutenbergContainerFragment().mediaFileSaveProgress(localId, progress); } - @Override public void onMediaSaveFailed(String localId) { + @Override + public void onMediaSaveFailed(String localId) { getGutenbergContainerFragment().mediaFileSaveFailed(localId); mFailedMediaIds.add(localId); mUploadingMediaProgressMax.remove(localId); } - @Override public void onStorySaveResult(String storyFirstMediaId, boolean success) { + @Override + public void onStorySaveResult(String storyFirstMediaId, boolean success) { if (!success) { mFailedMediaIds.add(storyFirstMediaId); } @@ -1502,11 +1551,13 @@ public void onEditorThemeUpdated(Bundle editorTheme) { getGutenbergContainerFragment().onStorySaveResult(storyFirstMediaId, success); } - @Override public void onMediaModelCreatedForFile(String oldId, String newId, String oldUrl) { + @Override + public void onMediaModelCreatedForFile(String oldId, String newId, String oldUrl) { getGutenbergContainerFragment().onMediaModelCreatedForFile(oldId, newId, oldUrl); } - @Override public void onStoryMediaSavedToRemote(String localId, String remoteId, String oldUrl, String newUrl) { + @Override + public void onStoryMediaSavedToRemote(String localId, String remoteId, String oldUrl, String newUrl) { mUploadingMediaProgressMax.remove(localId); // this method may end up being called twice if the original FluxC OnMediaUploaded event was correctly caught // when posted, and can be retriggered by StoriesEventListener in the case a Gutenberg instance is re-mounted @@ -1529,11 +1580,13 @@ public void showEditorHelp() { getGutenbergContainerFragment().showEditorHelp(); } - @Override public void onUndoPressed() { + @Override + public void onUndoPressed() { getGutenbergContainerFragment().onUndoPressed(); } - @Override public void onRedoPressed() { + @Override + public void onRedoPressed() { getGutenbergContainerFragment().onRedoPressed(); } From fb618efac8193db517432f1eafc153ff7dab617a Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 17 Aug 2023 18:09:03 +0300 Subject: [PATCH 04/29] Analysis: Add missing n-a to sdk override methods for gutenberg ctr FYI: 'n-a' stands for 'nullability annotations'. --- .../android/editor/gutenberg/GutenbergContainerFragment.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergContainerFragment.java b/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergContainerFragment.java index 5074f133ac56..04c4b14ebc06 100644 --- a/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergContainerFragment.java +++ b/libs/editor/src/main/java/org/wordpress/android/editor/gutenberg/GutenbergContainerFragment.java @@ -4,6 +4,7 @@ import android.os.Bundle; import android.view.ViewGroup; +import androidx.annotation.Nullable; import androidx.core.util.Consumer; import androidx.core.util.Pair; import androidx.fragment.app.Fragment; @@ -120,7 +121,7 @@ public void attachToContainer(ViewGroup viewGroup, OnMediaLibraryButtonListener } @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); GutenbergPropsBuilder gutenbergPropsBuilder = getArguments().getParcelable(ARG_GUTENBERG_PROPS_BUILDER); From 9fcf2811ba7e5fbfe7b85f5e26f61fedab1d260b Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 17 Aug 2023 18:13:34 +0300 Subject: [PATCH 05/29] Analysis: Add missing n-a to sdk override methods for shared intent rec FYI: 'n-a' stands for 'nullability annotations'. --- .../android/ui/ShareIntentReceiverFragment.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/ShareIntentReceiverFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/ShareIntentReceiverFragment.java index b762991027a1..7f6a81f0f038 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/ShareIntentReceiverFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/ShareIntentReceiverFragment.java @@ -9,6 +9,7 @@ import android.widget.Button; import android.widget.TextView; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.LinearLayoutManager; @@ -57,7 +58,7 @@ public static ShareIntentReceiverFragment newInstance(boolean sharingMediaFile, } @Override - public void onAttach(Context context) { + public void onAttach(@NonNull Context context) { super.onAttach(context); if (context instanceof ShareIntentFragmentListener) { mShareIntentFragmentListener = (ShareIntentFragmentListener) context; @@ -76,7 +77,7 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) { @Nullable @Override - public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { ViewGroup layout = (ViewGroup) inflater.inflate(R.layout.share_intent_receiver_fragment, container, false); initButtonsContainer(layout); @@ -95,14 +96,14 @@ public void onCreate(@Nullable Bundle savedInstanceState) { loadSavedState(savedInstanceState); } - private void loadSavedState(Bundle savedInstanceState) { + private void loadSavedState(@Nullable Bundle savedInstanceState) { if (savedInstanceState != null) { mLastUsedBlogLocalId = savedInstanceState.getInt(ARG_LAST_USED_BLOG_LOCAL_ID); } } @Override - public void onSaveInstanceState(Bundle outState) { + public void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); int selectedItemLocalId = mAdapter.getSelectedItemLocalId(); if (selectedItemLocalId != -1) { @@ -129,7 +130,7 @@ private void initShareActionMediaButton(final ViewGroup layout, boolean sharingM private void addShareActionListener(final Button button, final ShareAction shareAction) { button.setOnClickListener(new OnClickListener() { @Override - public void onClick(View v) { + public void onClick(@NonNull View v) { mShareIntentFragmentListener.share(shareAction, mAdapter.getSelectedItemLocalId()); } }); From d382dd5412c8b47953e28c7232824895a8b44107 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 17 Aug 2023 18:17:36 +0300 Subject: [PATCH 06/29] Analysis: Add missing n-a to sdk override methods for login epilogue FYI: 'n-a' stands for 'nullability annotations'. --- .../ui/accounts/login/LoginEpilogueFragment.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/login/LoginEpilogueFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/accounts/login/LoginEpilogueFragment.java index 9e58fd67aef0..cdb951af79d9 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/login/LoginEpilogueFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/login/LoginEpilogueFragment.java @@ -154,7 +154,7 @@ protected void setupBottomButton(Button button) { } @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDoLoginUpdate = requireArguments().getBoolean(ARG_DO_LOGIN_UPDATE, false); @@ -165,7 +165,7 @@ public void onCreate(Bundle savedInstanceState) { } @Override - public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); initViewModel(); } @@ -301,7 +301,7 @@ public boolean onSiteLongClick(SiteRecord site) { } @Override - public void onAttach(Context context) { + public void onAttach(@NonNull Context context) { super.onAttach(context); if (context instanceof LoginEpilogueListener) { mLoginEpilogueListener = (LoginEpilogueListener) context; @@ -370,15 +370,15 @@ private void bindFooterViewHolder(LoginFooterViewHolder holder, SiteList sites) } @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { + public void beforeTextChanged(@NonNull CharSequence s, int start, int count, int after) { } @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { + public void onTextChanged(@NonNull CharSequence s, int start, int before, int count) { } @Override - public void afterTextChanged(Editable s) { + public void afterTextChanged(@NonNull Editable s) { } @Override From 1d2776ee27a52b3e1b57067a4fb83cfaec2a2395 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 17 Aug 2023 18:24:16 +0300 Subject: [PATCH 07/29] Analysis: Add missing n-a to sdk override methods for signup epilogue FYI: 'n-a' stands for 'nullability annotations'. --- .../signup/SignupEpilogueFragment.java | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/signup/SignupEpilogueFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/accounts/signup/SignupEpilogueFragment.java index 5792d56c0eac..d90893b1df3e 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/signup/SignupEpilogueFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/signup/SignupEpilogueFragment.java @@ -188,14 +188,14 @@ protected void setupContent(ViewGroup rootView) { headerAvatarLayout.setEnabled(mIsEmailSignup); headerAvatarLayout.setOnClickListener(new View.OnClickListener() { @Override - public void onClick(View view) { + public void onClick(@NonNull View v) { mUnifiedLoginTracker.trackClick(Click.SELECT_AVATAR); mMediaPickerLauncher.showGravatarPicker(SignupEpilogueFragment.this); } }); headerAvatarLayout.setOnLongClickListener(new View.OnLongClickListener() { @Override - public boolean onLongClick(View view) { + public boolean onLongClick(@NonNull View v) { ToastUtils.showToast(getActivity(), getString(R.string.content_description_add_avatar), ToastUtils.Duration.SHORT); return true; @@ -214,15 +214,15 @@ public boolean onLongClick(View view) { mEditTextDisplayName.setText(mDisplayName); mEditTextDisplayName.addTextChangedListener(new TextWatcher() { @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { + public void beforeTextChanged(@NonNull CharSequence s, int start, int count, int after) { } @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { + public void onTextChanged(@NonNull CharSequence s, int start, int before, int count) { } @Override - public void afterTextChanged(Editable s) { + public void afterTextChanged(@NonNull Editable s) { mDisplayName = s.toString(); mHeaderDisplayName.setText(mDisplayName); } @@ -232,14 +232,14 @@ public void afterTextChanged(Editable s) { mEditTextUsername.setText(mUsername); mEditTextUsername.setOnClickListener(new View.OnClickListener() { @Override - public void onClick(View view) { + public void onClick(@NonNull View v) { mUnifiedLoginTracker.trackClick(Click.EDIT_USERNAME); launchDialog(); } }); mEditTextUsername.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override - public void onFocusChange(View view, boolean hasFocus) { + public void onFocusChange(@NonNull View v, boolean hasFocus) { if (hasFocus) { launchDialog(); } @@ -247,7 +247,7 @@ public void onFocusChange(View view, boolean hasFocus) { }); mEditTextUsername.setOnKeyListener(new View.OnKeyListener() { @Override - public boolean onKey(View view, int keyCode, KeyEvent event) { + public boolean onKey(@NonNull View v, int keyCode, @NonNull KeyEvent event) { // Consume keyboard events except for Enter (i.e. click/tap) and Tab (i.e. focus/navigation). // The onKey method returns true if the listener has consumed the event and false otherwise // allowing hardware keyboard users to tap and navigate, but not input text as expected. @@ -269,7 +269,8 @@ public boolean onKey(View view, int keyCode, KeyEvent event) { (OnScrollChangeListener) (v, scrollX, scrollY, oldScrollX, oldScrollY) -> showBottomShadowIfNeeded()); // We must use onGlobalLayout here otherwise canScrollVertically will always return false mScrollView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { - @Override public void onGlobalLayout() { + @Override + public void onGlobalLayout() { mScrollView.getViewTreeObserver().removeOnGlobalLayoutListener(this); showBottomShadowIfNeeded(); } @@ -289,7 +290,7 @@ private void showBottomShadowIfNeeded() { protected void setupBottomButton(Button button) { button.setOnClickListener(new View.OnClickListener() { @Override - public void onClick(View view) { + public void onClick(@NonNull View v) { mUnifiedLoginTracker.trackClick(Click.CONTINUE); updateAccountOrContinue(); } @@ -297,7 +298,7 @@ public void onClick(View view) { } @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getActivity().getApplication()).component().inject(this); mDispatcher.dispatch(AccountActionBuilder.newFetchAccountAction()); @@ -364,7 +365,7 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) { @Override @SuppressWarnings("deprecation") - public void onActivityResult(int requestCode, int resultCode, Intent data) { + public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); if (isAdded()) { @@ -434,7 +435,7 @@ public void doNext(Uri uri) { } @Override - public void onAttach(Context context) { + public void onAttach(@NonNull Context context) { super.onAttach(context); if (context instanceof SignupEpilogueListener) { @@ -468,7 +469,7 @@ public void onShown() { } @Override - public void onSaveInstanceState(Bundle outState) { + public void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); outState.putString(KEY_PHOTO_URL, mPhotoUrl); outState.putString(KEY_DISPLAY_NAME, mDisplayName); @@ -482,15 +483,15 @@ public void onSaveInstanceState(Bundle outState) { } @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { + public void beforeTextChanged(@NonNull CharSequence s, int start, int count, int after) { } @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { + public void onTextChanged(@NonNull CharSequence s, int start, int before, int count) { } @Override - public void afterTextChanged(Editable s) { + public void afterTextChanged(@NonNull Editable s) { } @Override @@ -665,7 +666,7 @@ private void populateViews() { protected void showErrorDialog(String message) { DialogInterface.OnClickListener dialogListener = new DialogInterface.OnClickListener() { @Override - public void onClick(DialogInterface dialog, int which) { + public void onClick(@Nullable DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_NEGATIVE: undoChanges(); From 28135d1dae7dae7edf5ddb9114bf6f23e7bd6cc4 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 18 Aug 2023 12:49:44 +0300 Subject: [PATCH 08/29] Analysis: Add missing n-a to sdk override methods for comment detail FYI: 'n-a' stands for 'nullability annotations'. --- .../ui/comments/CommentDetailFragment.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentDetailFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentDetailFragment.java index e5bcb7f8288b..039bf51964d8 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentDetailFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentDetailFragment.java @@ -224,7 +224,7 @@ public static CommentDetailFragment newInstance(final String noteId, final Strin } @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getActivity().getApplication()).component().inject(this); @@ -277,9 +277,11 @@ public void onDestroy() { } // touching the file resulted in the MethodLength, it's suppressed until we get time to refactor this method - @SuppressWarnings("checkstyle:MethodLength") + @Nullable @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + @SuppressWarnings("checkstyle:MethodLength") + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.comment_detail_fragment, container, false); mMediumOpacity = ResourcesCompat.getFloat( @@ -337,15 +339,15 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa mEditReply.initializeWithPrefix('@'); mEditReply.addTextChangedListener(new TextWatcher() { @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { + public void beforeTextChanged(@NonNull CharSequence s, int start, int count, int after) { } @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { + public void onTextChanged(@NonNull CharSequence s, int start, int before, int count) { } @Override - public void afterTextChanged(Editable s) { + public void afterTextChanged(@NonNull Editable s) { mSubmitReplyBtn.setEnabled(!TextUtils.isEmpty(s.toString().trim())); } }); @@ -641,7 +643,7 @@ public void onPause() { @Override @SuppressWarnings("deprecation") - public void onActivityResult(int requestCode, int resultCode, Intent data) { + public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == INTENT_COMMENT_EDITOR && resultCode == Activity.RESULT_OK) { reloadComment(); @@ -1639,8 +1641,9 @@ private void showSnackBar(String message) { } } + @Nullable @Override - @Nullable public View getScrollableViewForUniqueIdProvision() { + public View getScrollableViewForUniqueIdProvision() { return mNestedScrollView; } } From 24e283a8bb57d1b3b274424ec96dc93614b41fa4 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 18 Aug 2023 12:53:51 +0300 Subject: [PATCH 09/29] Analysis: Add missing n-a to sdk override methods for history detail FYI: 'n-a' stands for 'nullability annotations'. --- .../ui/history/HistoryDetailContainerFragment.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/history/HistoryDetailContainerFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/history/HistoryDetailContainerFragment.java index ee0b274f0f28..6b7ffbefccb7 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/history/HistoryDetailContainerFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/history/HistoryDetailContainerFragment.java @@ -100,8 +100,10 @@ public static HistoryDetailContainerFragment newInstance(final Revision revision return fragment; } + @Nullable @Override - public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.history_detail_container_fragment, container, false); mIsFragmentRecreated = savedInstanceState != null; @@ -227,20 +229,20 @@ public void onSaveInstanceState(@NonNull Bundle outState) { } @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.history_detail, menu); } @Override - public void onPrepareOptionsMenu(Menu menu) { + public void onPrepareOptionsMenu(@NonNull Menu menu) { super.onPrepareOptionsMenu(menu); MenuItem viewMode = menu.findItem(R.id.history_toggle_view); viewMode.setTitle(isInVisualPreview() ? R.string.history_preview_html : R.string.history_preview_visual); } @Override - public boolean onOptionsItemSelected(MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { if (item.getItemId() == R.id.history_load) { Intent intent = new Intent(); intent.putExtra(KEY_REVISION, mRevision); @@ -353,6 +355,7 @@ private class HistoryDetailFragmentAdapter extends FragmentStatePagerAdapter { mRevisions = (ArrayList) revisions.clone(); } + @NonNull @Override public Fragment getItem(int position) { return HistoryDetailFragment.Companion.newInstance(mRevisions.get(position)); @@ -364,7 +367,7 @@ public int getCount() { } @Override - public void restoreState(Parcelable state, ClassLoader loader) { + public void restoreState(@Nullable Parcelable state, @Nullable ClassLoader loader) { try { super.restoreState(state, loader); } catch (IllegalStateException exception) { @@ -372,6 +375,7 @@ public void restoreState(Parcelable state, ClassLoader loader) { } } + @Nullable @Override public Parcelable saveState() { Bundle bundle = (Bundle) super.saveState(); From b85771d0e6c9055ee8ddc2401530b41fbc620ce1 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 18 Aug 2023 12:57:59 +0300 Subject: [PATCH 10/29] Analysis: Add missing n-a to sdk override methods for media grid FYI: 'n-a' stands for 'nullability annotations'. --- .../android/ui/media/MediaGridFragment.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaGridFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaGridFragment.java index 2ea31b5bbc41..201d3fc607af 100755 --- a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaGridFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaGridFragment.java @@ -15,6 +15,7 @@ import android.view.ViewGroup; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.view.ActionMode; import androidx.fragment.app.Fragment; @@ -197,7 +198,7 @@ public static MediaGridFragment newInstance(@NonNull SiteModel site, } @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getActivity().getApplication()).component().inject(this); @@ -268,14 +269,16 @@ private View getSnackbarParent() { } @Override - public void onSaveInstanceState(Bundle outState) { + public void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); outState.putParcelable(QuickStartEvent.KEY, mQuickStartEvent); saveState(outState); } + @Nullable @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View view = inflater.inflate(R.layout.media_grid_fragment, container, false); @@ -301,7 +304,7 @@ public boolean onFling(int velocityX, int velocityY) { }); mRecycler.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override - public void onScrollStateChanged(RecyclerView recyclerView, int newState) { + public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); if (newState == RecyclerView.SCROLL_STATE_IDLE) { getAdapter().setLoadThumbnails(true); @@ -311,7 +314,8 @@ public void onScrollStateChanged(RecyclerView recyclerView, int newState) { mActionableEmptyView = (ActionableEmptyView) view.findViewById(R.id.actionable_empty_view); mActionableEmptyView.button.setOnClickListener(new OnClickListener() { - @Override public void onClick(View view) { + @Override + public void onClick(@NonNull View v) { if (isAdded() && getActivity() instanceof MediaBrowserActivity) { ((MediaBrowserActivity) getActivity()).showAddMediaPopup(); } @@ -359,7 +363,7 @@ private MediaGridAdapter getAdapter() { } @Override - public void onAttach(Activity activity) { + public void onAttach(@NonNull Activity activity) { super.onAttach(activity); try { @@ -849,7 +853,7 @@ private void setResultIdsAndFinish() { private final class ActionModeCallback implements ActionMode.Callback { @Override - public boolean onCreateActionMode(ActionMode mode, Menu menu) { + public boolean onCreateActionMode(@NonNull ActionMode mode, @NonNull Menu menu) { mActionMode = mode; int selectCount = getAdapter().getSelectedItemCount(); MenuInflater inflater = mode.getMenuInflater(); @@ -861,7 +865,7 @@ public boolean onCreateActionMode(ActionMode mode, Menu menu) { } @Override - public boolean onPrepareActionMode(ActionMode mode, Menu menu) { + public boolean onPrepareActionMode(@NonNull ActionMode mode, @NonNull Menu menu) { MenuItem mnuConfirm = menu.findItem(R.id.mnu_confirm_selection); mnuConfirm.setVisible(mBrowserType.isPicker()); @@ -870,7 +874,7 @@ public boolean onPrepareActionMode(ActionMode mode, Menu menu) { } @Override - public boolean onActionItemClicked(ActionMode mode, MenuItem item) { + public boolean onActionItemClicked(@NonNull ActionMode mode, @NonNull MenuItem item) { if (item.getItemId() == R.id.mnu_confirm_selection) { setResultIdsAndFinish(); } @@ -878,7 +882,7 @@ public boolean onActionItemClicked(ActionMode mode, MenuItem item) { } @Override - public void onDestroyActionMode(ActionMode mode) { + public void onDestroyActionMode(@NonNull ActionMode mode) { setSwipeToRefreshEnabled(true); getAdapter().setInMultiSelect(false); mActionMode = null; From a34eb193897934e43084430545c3e2f7fb8fe4e1 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 18 Aug 2023 13:00:02 +0300 Subject: [PATCH 11/29] Analysis: Add missing n-a to sdk override methods for media preview FYI: 'n-a' stands for 'nullability annotations'. --- .../wordpress/android/ui/media/MediaPreviewFragment.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaPreviewFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaPreviewFragment.java index 5c028bf98d67..53ddfabef512 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaPreviewFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaPreviewFragment.java @@ -146,8 +146,10 @@ public void onCreate(@Nullable Bundle savedInstanceState) { } } + @Nullable @Override - public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View view = inflater.inflate(R.layout.media_preview_fragment, container, false); @@ -330,7 +332,8 @@ boolean showAudioOrVideo() { } private class PlayerEventListener implements Player.EventListener { - @Override public void onLoadingChanged(boolean isLoading) { + @Override + public void onLoadingChanged(boolean isLoading) { showProgress(isLoading); } } From 021ee48d3e6b77af423c62302be4ec88d62161ed Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 18 Aug 2023 13:02:57 +0300 Subject: [PATCH 12/29] Analysis: Add missing n-a to sdk override methods for people invite FYI: 'n-a' stands for 'nullability annotations'. --- .../ui/people/PeopleInviteFragment.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleInviteFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleInviteFragment.java index 5e2f2260fcf6..e071e8cb1174 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleInviteFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleInviteFragment.java @@ -133,19 +133,19 @@ private void updateSiteOrFinishActivity() { } @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) { inflater.inflate(R.menu.people_invite, menu); super.onCreateOptionsMenu(menu, inflater); } @Override - public void onPrepareOptionsMenu(Menu menu) { + public void onPrepareOptionsMenu(@NonNull Menu menu) { menu.getItem(0).setEnabled(!mInviteOperationInProgress); // here pass the index of send menu item super.onPrepareOptionsMenu(menu); } @Override - public void onSaveInstanceState(Bundle outState) { + public void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); if (mCurrentRole != null) { outState.putString(KEY_SELECTED_ROLE, mCurrentRole); @@ -154,7 +154,7 @@ public void onSaveInstanceState(Bundle outState) { } @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getActivity().getApplicationContext()).component().inject(this); updateSiteOrFinishActivity(); @@ -178,8 +178,10 @@ public void onCreate(Bundle savedInstanceState) { setRetainInstance(true); } + @Nullable @Override - public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { setHasOptionsMenu(true); View rootView = inflater.inflate(R.layout.people_invite_fragment, container, false); @@ -329,11 +331,13 @@ public void onViewStateRestored(@Nullable Bundle savedInstanceState) { } mUsernamesEmails.setItemsManager(new ItemsManagerInterface() { - @Override public void onRemoveItem(@NonNull String item) { + @Override + public void onRemoveItem(@NonNull String item) { removeUsername(item); } - @Override public void onAddItem(@NonNull String item) { + @Override + public void onAddItem(@NonNull String item) { addUsername(item, null); } }); @@ -375,16 +379,16 @@ public void onViewStateRestored(@Nullable Bundle savedInstanceState) { mCustomMessageEditText.addTextChangedListener(new TextWatcher() { @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { + public void beforeTextChanged(@NonNull CharSequence s, int start, int count, int after) { } @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { + public void onTextChanged(@NonNull CharSequence s, int start, int before, int count) { mCustomMessage = mCustomMessageEditText.getText().toString(); } @Override - public void afterTextChanged(Editable s) { + public void afterTextChanged(@NonNull Editable s) { } }); From 2b493e16de24d5c66112390df607e74a8ed812a7 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 18 Aug 2023 13:05:49 +0300 Subject: [PATCH 13/29] Analysis: Add missing n-a to sdk override methods for people list FYI: 'n-a' stands for 'nullability annotations'. --- .../android/ui/people/PeopleListFragment.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleListFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleListFragment.java index a960bd26c5a7..fb19c0a2018d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleListFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleListFragment.java @@ -93,19 +93,21 @@ public void onDetach() { } @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getActivity().getApplicationContext()).component().inject(this); } @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) { inflater.inflate(R.menu.people_list, menu); super.onCreateOptionsMenu(menu, inflater); } + @Nullable @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { setHasOptionsMenu(true); final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.people_list_fragment, container, false); @@ -260,7 +262,8 @@ private void showJetpackBannerIfNeeded(final View rootView) { } } - @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); // important for accessibility - talkback getActivity().setTitle(R.string.people); @@ -474,7 +477,8 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi } } - @Override public void onViewRecycled(@NonNull ViewHolder holder) { + @Override + public void onViewRecycled(@NonNull ViewHolder holder) { super.onViewRecycled(holder); PeopleViewHolder peopleViewHolder = (PeopleViewHolder) holder; } @@ -498,7 +502,7 @@ public PeopleViewHolder(View view) { } @Override - public void onClick(View v) { + public void onClick(@NonNull View v) { if (mOnPersonSelectedListener != null) { Person person = getPerson(getBindingAdapterPosition()); mOnPersonSelectedListener.onPersonSelected(person); From 61a9fbb579293fe2d365ddead99646623afa6952 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 18 Aug 2023 13:06:52 +0300 Subject: [PATCH 14/29] Analysis: Add missing n-a to sdk override methods for person detail FYI: 'n-a' stands for 'nullability annotations'. --- .../android/ui/people/PersonDetailFragment.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/people/PersonDetailFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/people/PersonDetailFragment.java index 33527e1e6932..c28eb2944464 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/people/PersonDetailFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/people/PersonDetailFragment.java @@ -12,6 +12,7 @@ import android.widget.TextView; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; @@ -80,7 +81,7 @@ public static PersonDetailFragment newInstance(long currentUserId, long personId } @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getActivity().getApplicationContext()).component().inject(this); @@ -110,13 +111,15 @@ public void onSaveInstanceState(@NonNull Bundle outState) { } @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) { inflater.inflate(R.menu.person_detail, menu); super.onCreateOptionsMenu(menu, inflater); } + @Nullable @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.person_detail_fragment, container, false); Toolbar toolbar = rootView.findViewById(R.id.toolbar_main); From 19cf29affad913fec1d0b7169b018c478e2f3839 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 18 Aug 2023 13:09:47 +0300 Subject: [PATCH 15/29] Analysis: Add missing n-a to sdk override methods for plugin list FYI: 'n-a' stands for 'nullability annotations'. --- .../ui/plugins/PluginListFragment.java | 67 +++++++++++-------- 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginListFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginListFragment.java index 588d39e51c55..4801753f14de 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginListFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginListFragment.java @@ -71,7 +71,7 @@ public static PluginListFragment newInstance(@NonNull SiteModel site, @NonNull P } @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getActivity().getApplication()).component().inject(this); @@ -133,8 +133,10 @@ private void setupObservers() { }); } + @Nullable @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.plugin_list_fragment, container, false); mRecycler = view.findViewById(R.id.recycler); @@ -154,7 +156,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa } @Override - public void onCreateOptionsMenu(Menu menu, @NonNull MenuInflater inflater) { + public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) { menu.clear(); super.onCreateOptionsMenu(menu, inflater); } @@ -211,7 +213,8 @@ void setPlugins(@NonNull List items) { diffResult.dispatchUpdatesTo(this); } - private @Nullable Object getItem(int position) { + @Nullable + private Object getItem(int position) { return mItems.getItem(position); } @@ -233,16 +236,16 @@ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int } @Override - public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) { + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { ImmutablePluginModel plugin = (ImmutablePluginModel) getItem(position); if (plugin == null) { return; } - PluginViewHolder holder = (PluginViewHolder) viewHolder; - holder.mName.setText(plugin.getDisplayName()); - holder.mAuthor.setText(plugin.getAuthorName()); - mImageManager.load(holder.mIcon, ImageType.PLUGIN, StringUtils.notNullStr(plugin.getIcon())); + PluginViewHolder pluginHolder = (PluginViewHolder) holder; + pluginHolder.mName.setText(plugin.getDisplayName()); + pluginHolder.mAuthor.setText(plugin.getAuthorName()); + mImageManager.load(pluginHolder.mIcon, ImageType.PLUGIN, StringUtils.notNullStr(plugin.getIcon())); if (plugin.isInstalled()) { @StringRes int textResId; @@ -250,38 +253,46 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int po @DrawableRes int drawableResId; if (PluginUtils.isAutoManaged(mViewModel.getSite(), plugin)) { textResId = R.string.plugin_auto_managed; - colorResId = ContextExtensionsKt - .getColorResIdFromAttribute(holder.mStatusIcon.getContext(), R.attr.wpColorSuccess); + colorResId = ContextExtensionsKt.getColorResIdFromAttribute( + pluginHolder.mStatusIcon.getContext(), + R.attr.wpColorSuccess + ); drawableResId = android.R.color.transparent; } else if (PluginUtils.isUpdateAvailable(plugin)) { textResId = R.string.plugin_needs_update; - colorResId = ContextExtensionsKt - .getColorResIdFromAttribute(holder.mStatusIcon.getContext(), R.attr.wpColorWarningDark); + colorResId = ContextExtensionsKt.getColorResIdFromAttribute( + pluginHolder.mStatusIcon.getContext(), + R.attr.wpColorWarningDark + ); drawableResId = R.drawable.ic_sync_white_24dp; } else if (plugin.isActive()) { textResId = R.string.plugin_active; - colorResId = ContextExtensionsKt - .getColorResIdFromAttribute(holder.mStatusIcon.getContext(), R.attr.wpColorSuccess); + colorResId = ContextExtensionsKt.getColorResIdFromAttribute( + pluginHolder.mStatusIcon.getContext(), + R.attr.wpColorSuccess + ); drawableResId = R.drawable.ic_checkmark_white_24dp; } else { textResId = R.string.plugin_inactive; - colorResId = ContextExtensionsKt - .getColorResIdFromAttribute(holder.mStatusIcon.getContext(), R.attr.wpColorOnSurfaceMedium); + colorResId = ContextExtensionsKt.getColorResIdFromAttribute( + pluginHolder.mStatusIcon.getContext(), + R.attr.wpColorOnSurfaceMedium + ); drawableResId = R.drawable.ic_cross_white_24dp; } - holder.mStatusText.setText(textResId); - holder.mStatusText.setTextColor( - AppCompatResources.getColorStateList(holder.mStatusText.getContext(), colorResId)); - ColorUtils.INSTANCE.setImageResourceWithTint(holder.mStatusIcon, drawableResId, colorResId); - holder.mStatusText.setVisibility(View.VISIBLE); - holder.mStatusIcon.setVisibility(View.VISIBLE); - holder.mRatingBar.setVisibility(View.GONE); + pluginHolder.mStatusText.setText(textResId); + pluginHolder.mStatusText.setTextColor( + AppCompatResources.getColorStateList(pluginHolder.mStatusText.getContext(), colorResId)); + ColorUtils.INSTANCE.setImageResourceWithTint(pluginHolder.mStatusIcon, drawableResId, colorResId); + pluginHolder.mStatusText.setVisibility(View.VISIBLE); + pluginHolder.mStatusIcon.setVisibility(View.VISIBLE); + pluginHolder.mRatingBar.setVisibility(View.GONE); } else { - holder.mStatusText.setVisibility(View.GONE); - holder.mStatusIcon.setVisibility(View.GONE); - holder.mRatingBar.setVisibility(View.VISIBLE); - holder.mRatingBar.setRating(plugin.getAverageStarRating()); + pluginHolder.mStatusText.setVisibility(View.GONE); + pluginHolder.mStatusIcon.setVisibility(View.GONE); + pluginHolder.mRatingBar.setVisibility(View.VISIBLE); + pluginHolder.mRatingBar.setRating(plugin.getAverageStarRating()); } if (position == getItemCount() - 1) { From 1b619a91209c859920ac82b69f3656454d081de0 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 18 Aug 2023 13:40:47 +0300 Subject: [PATCH 16/29] Analysis: Add missing n-a to sdk override methods for edit post settings FYI: 'n-a' stands for 'nullability annotations'. --- .../ui/posts/EditPostSettingsFragment.java | 52 +++++++++++-------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostSettingsFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostSettingsFragment.java index 17a68c9c050c..b9c0c98dda37 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostSettingsFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostSettingsFragment.java @@ -180,7 +180,7 @@ public static EditPostSettingsFragment newInstance() { } @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getActivity().getApplicationContext()).component().inject(this); mDispatcher.register(this); @@ -256,7 +256,8 @@ public void onCredentialsValidated(Exception error) { } } - @Override public void onResume() { + @Override + public void onResume() { super.onResume(); mJetpackSocialViewModel.onResume(JetpackSocialFlow.POST_SETTINGS); } @@ -270,6 +271,7 @@ public void onDestroy() { super.onDestroy(); } + @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { @@ -309,8 +311,8 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c OnClickListener showContextMenuListener = new View.OnClickListener() { @Override - public void onClick(View view) { - view.showContextMenu(); + public void onClick(@NonNull View v) { + v.showContextMenu(); } }; @@ -326,7 +328,7 @@ public void onClick(View view) { mFeaturedImageButton.setOnClickListener(new View.OnClickListener() { @Override - public void onClick(View view) { + public void onClick(@NonNull View v) { launchFeaturedMediaPicker(); } }); @@ -334,7 +336,7 @@ public void onClick(View view) { mExcerptContainer = rootView.findViewById(R.id.post_excerpt_container); mExcerptContainer.setOnClickListener(new View.OnClickListener() { @Override - public void onClick(View view) { + public void onClick(@NonNull View v) { showPostExcerptDialog(); } }); @@ -342,7 +344,7 @@ public void onClick(View view) { LinearLayout parentContainer = rootView.findViewById(R.id.post_parent_container); parentContainer.setOnClickListener(new View.OnClickListener() { @Override - public void onClick(View view) { + public void onClick(@NonNull View v) { showPageParentActivity(); } }); @@ -350,7 +352,7 @@ public void onClick(View view) { final LinearLayout slugContainer = rootView.findViewById(R.id.post_slug_container); slugContainer.setOnClickListener(new View.OnClickListener() { @Override - public void onClick(View view) { + public void onClick(@NonNull View v) { showSlugDialog(); } }); @@ -360,7 +362,7 @@ public void onClick(View view) { LinearLayout categoriesContainer = rootView.findViewById(R.id.post_categories_container); categoriesContainer.setOnClickListener(new View.OnClickListener() { @Override - public void onClick(View view) { + public void onClick(@NonNull View v) { showCategoriesActivity(); } }); @@ -368,7 +370,7 @@ public void onClick(View view) { LinearLayout tagsContainer = rootView.findViewById(R.id.post_tags_container); tagsContainer.setOnClickListener(new View.OnClickListener() { @Override - public void onClick(View view) { + public void onClick(@NonNull View v) { showTagsActivity(); } }); @@ -376,7 +378,7 @@ public void onClick(View view) { final LinearLayout statusContainer = rootView.findViewById(R.id.post_status_container); statusContainer.setOnClickListener(new View.OnClickListener() { @Override - public void onClick(View view) { + public void onClick(@NonNull View v) { showStatusDialog(); } }); @@ -384,7 +386,7 @@ public void onClick(View view) { mFormatContainer = rootView.findViewById(R.id.post_format_container); mFormatContainer.setOnClickListener(new View.OnClickListener() { @Override - public void onClick(View view) { + public void onClick(@NonNull View v) { showPostFormatDialog(); } }); @@ -394,14 +396,14 @@ public void onClick(View view) { final LinearLayout passwordContainer = rootView.findViewById(R.id.post_password_container); passwordContainer.setOnClickListener(new View.OnClickListener() { @Override - public void onClick(View view) { + public void onClick(@NonNull View v) { showPostPasswordDialog(); } }); mPublishDateContainer.setOnClickListener(new View.OnClickListener() { @Override - public void onClick(View view) { + public void onClick(@NonNull View v) { FragmentActivity activity = getActivity(); if (activity instanceof EditPostSettingsCallback) { ((EditPostSettingsCallback) activity).onEditPostPublishedSettingsClick(); @@ -418,13 +420,15 @@ public void onClick(View view) { mPublishedViewModel.getOnUiModel().observe(getViewLifecycleOwner(), new Observer() { - @Override public void onChanged(PublishUiModel uiModel) { + @Override + public void onChanged(@NonNull PublishUiModel uiModel) { updatePublishDateTextView(uiModel.getPublishDateLabel(), Objects.requireNonNull(getEditPostRepository().getPost())); } }); mPublishedViewModel.getOnPostStatusChanged().observe(getViewLifecycleOwner(), new Observer() { - @Override public void onChanged(PostStatus postStatus) { + @Override + public void onChanged(@NonNull PostStatus postStatus) { updatePostStatus(postStatus); } }); @@ -438,7 +442,8 @@ public void onClick(View view) { return rootView; } - @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); setupJetpackSocialViewModel(); } @@ -470,7 +475,8 @@ private void observeJetpackSocialUiState() { } @Override - public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { + public void onCreateContextMenu(@NonNull ContextMenu menu, @NonNull View v, + @Nullable ContextMenu.ContextMenuInfo menuInfo) { if (mFeaturedImageRetryOverlay.getVisibility() == View.VISIBLE) { menu.add(0, RETRY_FEATURED_IMAGE_UPLOAD_MENU_ID, 0, getString(R.string.post_settings_retry_featured_image)); @@ -483,7 +489,7 @@ public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMen } @Override - public boolean onContextItemSelected(MenuItem item) { + public boolean onContextItemSelected(@NonNull MenuItem item) { SiteModel site = getSite(); PostImmutableModel post = getEditPostRepository().getPost(); if (site == null || post == null) { @@ -558,7 +564,7 @@ public void refreshViews() { @Override @SuppressWarnings("deprecation") - public void onActivityResult(int requestCode, int resultCode, Intent data) { + public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); if (data != null || ((requestCode == RequestCodes.TAKE_PHOTO @@ -1275,10 +1281,12 @@ private void updateFeaturedImageView(PostImmutableModel postModel) { mImageManager.loadWithResultListener(mFeaturedImageView, ImageType.IMAGE, currentFeaturedImageState.getMediaUri(), ScaleType.FIT_CENTER, null, new RequestListener() { - @Override public void onLoadFailed(@Nullable Exception e, @Nullable Object model) { + @Override + public void onLoadFailed(@Nullable Exception e, @Nullable Object model) { } - @Override public void onResourceReady(@NonNull Drawable resource, @Nullable Object model) { + @Override + public void onResourceReady(@NonNull Drawable resource, @Nullable Object model) { if (currentFeaturedImageState.getUiState() == FeaturedImageState.REMOTE_IMAGE_LOADING) { updateFeaturedImageViews(FeaturedImageState.REMOTE_IMAGE_SET); } From a4521c76275e23038fc2cadd4f4ac5fce6a42c5a Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 18 Aug 2023 13:43:51 +0300 Subject: [PATCH 17/29] Analysis: Add missing n-a to sdk override methods for tags FYI: 'n-a' stands for 'nullability annotations'. --- .../android/ui/posts/TagsFragment.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/TagsFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/TagsFragment.java index 1592b3ccd372..4a31a0f4d69d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/TagsFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/TagsFragment.java @@ -52,7 +52,8 @@ public TagsFragment() { protected abstract String getTagsFromEditPostRepositoryOrArguments(); - @Override public void onCreate(@Nullable Bundle savedInstanceState) { + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null) { @@ -65,19 +66,22 @@ public TagsFragment() { } } - @Override public void onDetach() { + @Override + public void onDetach() { super.onDetach(); mTagsSelectedListener = null; } + @Nullable @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(getContentLayout(), container, false); } - @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.tags_suggestion_list); @@ -123,7 +127,7 @@ public void onStop() { } @Override - public boolean onKey(View view, int keyCode, KeyEvent keyEvent) { + public boolean onKey(@NonNull View view, int keyCode, @NonNull KeyEvent keyEvent) { if ((keyEvent.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { // Since we don't allow new lines, we should add comma on "enter" to separate the tags @@ -138,18 +142,18 @@ public boolean onKey(View view, int keyCode, KeyEvent keyEvent) { } @Override - public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { + public void beforeTextChanged(@NonNull CharSequence s, int start, int count, int after) { // No-op } @Override - public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { + public void onTextChanged(@NonNull CharSequence s, int start, int before, int count) { filterListForCurrentText(); - mTagsSelectedListener.onTagsSelected(charSequence.toString()); + mTagsSelectedListener.onTagsSelected(s.toString()); } @Override - public void afterTextChanged(Editable editable) { + public void afterTextChanged(@NonNull Editable s) { // No-op } From 625c4d7e810af8b2deebcd30cab757afd84f1210 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 18 Aug 2023 13:45:02 +0300 Subject: [PATCH 18/29] Analysis: Add missing n-a to sdk override methods for my profile FYI: 'n-a' stands for 'nullability annotations'. --- .../org/wordpress/android/ui/prefs/MyProfileFragment.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/MyProfileFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/MyProfileFragment.java index 72529eb9c4cc..ccc7b3ccadac 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/MyProfileFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/MyProfileFragment.java @@ -7,6 +7,8 @@ import android.view.ViewGroup; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import org.greenrobot.eventbus.Subscribe; @@ -49,7 +51,7 @@ public static MyProfileFragment newInstance() { } @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getActivity().getApplication()).component().inject(this); } @@ -76,8 +78,10 @@ public void onStop() { super.onStop(); } + @Nullable @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.my_profile_fragment, container, false); mFirstName = rootView.findViewById(R.id.first_name); From 0eac8ccba74b54b864e355c791dd339026dd2c30 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 18 Aug 2023 13:49:53 +0300 Subject: [PATCH 19/29] Analysis: Add missing n-a to sdk override methods for site settings td FYI: 'n-a' stands for 'nullability annotations'. --- .../ui/prefs/SiteSettingsTagDetailFragment.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTagDetailFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTagDetailFragment.java index b2d22218bc6f..c3d51e378a73 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTagDetailFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTagDetailFragment.java @@ -63,15 +63,17 @@ public static SiteSettingsTagDetailFragment newInstance(@Nullable TermModel term } @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getActivity().getApplication()).component().inject(this); setHasOptionsMenu(true); } + @Nullable @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.site_settings_tag_detail_fragment, container, false); mNameView = view.findViewById(R.id.edit_name); @@ -95,20 +97,20 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) { } @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) { menu.clear(); inflater.inflate(R.menu.tag_detail, menu); super.onCreateOptionsMenu(menu, inflater); } @Override - public void onPrepareOptionsMenu(Menu menu) { + public void onPrepareOptionsMenu(@NonNull Menu menu) { super.onPrepareOptionsMenu(menu); menu.findItem(R.id.menu_trash).setVisible(!mIsNewTerm); } @Override - public boolean onOptionsItemSelected(final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { if (item.getItemId() == R.id.menu_trash && mListener != null) { mListener.onRequestDeleteTag(mTerm); return true; From d4f1612ad9ccd43ec7a04cbe10fd1c0ccbd1aaf3 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 18 Aug 2023 13:53:10 +0300 Subject: [PATCH 20/29] Analysis: Add missing n-a to sdk override methods for publicize detail FYI: 'n-a' stands for 'nullability annotations'. --- .../android/ui/publicize/PublicizeDetailFragment.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeDetailFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeDetailFragment.java index 40472ecc8d1b..1bb2d0f34fec 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeDetailFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeDetailFragment.java @@ -7,6 +7,7 @@ import android.widget.TextView; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.recyclerview.widget.RecyclerView; import org.wordpress.android.R; @@ -59,7 +60,7 @@ public static PublicizeDetailFragment newInstance(@NonNull SiteModel site, @NonN } @Override - public void setArguments(Bundle args) { + public void setArguments(@Nullable Bundle args) { super.setArguments(args); if (args != null) { @@ -69,7 +70,7 @@ public void setArguments(Bundle args) { } @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getActivity().getApplication()).component().inject(this); @@ -86,8 +87,10 @@ public void onSaveInstanceState(@NonNull Bundle outState) { outState.putString(PublicizeConstants.ARG_SERVICE_ID, mServiceId); } + @Nullable @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.publicize_detail_fragment, container, false); mConnectionsContainer = rootView.findViewById(R.id.connections_container); From 02d79721d91b4affb266f9c23c1fb5c06b317545 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 18 Aug 2023 13:54:30 +0300 Subject: [PATCH 21/29] Analysis: Add missing n-a to sdk override methods for publicize list FYI: 'n-a' stands for 'nullability annotations'. --- .../ui/publicize/PublicizeListFragment.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeListFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeListFragment.java index 73b7ebf59d91..aa3ae393a51a 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeListFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeListFragment.java @@ -98,7 +98,7 @@ public static PublicizeListFragment newInstance(@NonNull SiteModel site) { } @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getActivity().getApplication()).component().inject(this); @@ -130,8 +130,10 @@ public void onResume() { } } + @Nullable @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.publicize_list_fragment, container, false); mRecycler = rootView.findViewById(R.id.recycler_view); @@ -179,7 +181,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa return rootView; } - @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); initViewModel(); observeUIState(); @@ -266,13 +269,15 @@ public void onEvent(final QuickStartEvent event) { private void showQuickStartFocusPoint() { // we are waiting for RecyclerView to populate itself with views and then grab the first one when it's ready mRecycler.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { - @Override public void onGlobalLayout() { + @Override + public void onGlobalLayout() { RecyclerView.ViewHolder holder = mRecycler.findViewHolderForAdapterPosition(0); if (holder != null) { final View quickStartTarget = holder.itemView; quickStartTarget.post(new Runnable() { - @Override public void run() { + @Override + public void run() { if (getView() == null) { return; } @@ -371,12 +376,14 @@ void reload() { getAdapter().reload(); } - @Override public void onStart() { + @Override + public void onStart() { super.onStart(); EventBus.getDefault().register(this); } - @Override public void onStop() { + @Override + public void onStop() { super.onStop(); EventBus.getDefault().unregister(this); } From ee20b57e00195b198ef0f335a1b99381677a97a0 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 18 Aug 2023 14:05:20 +0300 Subject: [PATCH 22/29] Analysis: Add missing n-a to sdk override methods for publicize web view FYI: 'n-a' stands for 'nullability annotations'. --- .../publicize/PublicizeWebViewFragment.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeWebViewFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeWebViewFragment.java index 5bf106076191..4fd296c7e2e3 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeWebViewFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeWebViewFragment.java @@ -12,6 +12,7 @@ import android.widget.ProgressBar; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import org.greenrobot.eventbus.EventBus; import org.wordpress.android.R; @@ -60,7 +61,7 @@ public static PublicizeWebViewFragment newInstance(@NonNull SiteModel site, } @Override - public void setArguments(Bundle args) { + public void setArguments(@Nullable Bundle args) { super.setArguments(args); if (args != null) { @@ -71,7 +72,7 @@ public void setArguments(Bundle args) { } @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getActivity().getApplication()).component().inject(this); @@ -83,7 +84,7 @@ public void onCreate(Bundle savedInstanceState) { } @Override - public void onSaveInstanceState(Bundle outState) { + public void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); outState.putSerializable(WordPress.SITE, mSite); outState.putInt(PublicizeConstants.ARG_CONNECTION_ID, mConnectionId); @@ -91,8 +92,10 @@ public void onSaveInstanceState(Bundle outState) { mWebView.saveState(outState); } + @Nullable @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.publicize_webview_fragment, container, false); mProgress = rootView.findViewById(R.id.progress); @@ -109,7 +112,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa @Override @SuppressWarnings("deprecation") - public void onActivityCreated(Bundle savedInstanceState) { + public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (savedInstanceState == null) { @@ -165,7 +168,7 @@ private class PublicizeWebViewClient extends WebViewClient { } @Override - public void onPageFinished(WebView view, String url) { + public void onPageFinished(@NonNull WebView view, @Nullable String url) { super.onPageFinished(view, url); // does this url denotes that we made it past the auth stage? @@ -197,7 +200,7 @@ private class PublicizeWebChromeClient extends WebChromeClientWithVideoPoster { } @Override - public void onProgressChanged(WebView view, int newProgress) { + public void onProgressChanged(@NonNull WebView view, int newProgress) { super.onProgressChanged(view, newProgress); if (newProgress == 100 && isAdded()) { mProgress.setVisibility(View.GONE); @@ -205,7 +208,7 @@ public void onProgressChanged(WebView view, int newProgress) { } @Override - public void onReceivedTitle(WebView view, String title) { + public void onReceivedTitle(@NonNull WebView view, @Nullable String title) { super.onReceivedTitle(view, title); if (title != null && !title.startsWith("http")) { setTitle(title); From cb7ff06e49c0fa148bcd15b233d86bb76b66c411 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 18 Aug 2023 14:10:40 +0300 Subject: [PATCH 23/29] Analysis: Add missing n-a to sdk override methods for reader blog FYI: 'n-a' stands for 'nullability annotations'. --- .../android/ui/reader/ReaderBlogFragment.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderBlogFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderBlogFragment.java index 7e6c66578558..006fda0dbc8c 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderBlogFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderBlogFragment.java @@ -11,6 +11,7 @@ import android.view.ViewGroup; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.widget.SearchView; import androidx.fragment.app.Fragment; @@ -56,13 +57,13 @@ static ReaderBlogFragment newInstance(ReaderBlogType blogType) { } @Override - public void setArguments(Bundle args) { + public void setArguments(@Nullable Bundle args) { super.setArguments(args); restoreState(args); } @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getActivity().getApplication()).component().inject(this); if (savedInstanceState != null) { @@ -72,8 +73,10 @@ public void onCreate(Bundle savedInstanceState) { } } + @Nullable @Override - public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.reader_fragment_list, container, false); mRecyclerView = view.findViewById(R.id.recycler_view); @@ -100,7 +103,8 @@ private void checkEmptyView() { actionableEmptyView.subtitle.setText(R.string.reader_empty_followed_blogs_description); actionableEmptyView.button.setText(R.string.reader_empty_followed_blogs_button_discover); actionableEmptyView.button.setOnClickListener(new OnClickListener() { - @Override public void onClick(View view) { + @Override + public void onClick(@NonNull View v) { ReaderTag tag = ReaderUtils.getTagFromEndpoint(ReaderTag.DISCOVER_PATH); if (!ReaderTagTable.tagExists(tag)) { @@ -139,7 +143,7 @@ private void checkEmptyView() { @Override @SuppressWarnings("deprecation") - public void onActivityCreated(Bundle savedInstanceState) { + public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mRecyclerView.setAdapter(getBlogAdapter()); } @@ -153,7 +157,7 @@ public void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); } - private void restoreState(Bundle args) { + private void restoreState(@Nullable Bundle args) { if (args != null) { if (args.containsKey(ARG_BLOG_TYPE)) { mBlogType = (ReaderBlogType) args.getSerializable(ARG_BLOG_TYPE); @@ -174,7 +178,7 @@ public void onResume() { * note this will only be called for followed blogs */ @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); inflater.inflate(R.menu.reader_subs, menu); @@ -185,25 +189,25 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { searchMenu.setOnActionExpandListener(new MenuItem.OnActionExpandListener() { @Override - public boolean onMenuItemActionExpand(MenuItem item) { + public boolean onMenuItemActionExpand(@NonNull MenuItem item) { return true; } @Override - public boolean onMenuItemActionCollapse(MenuItem item) { + public boolean onMenuItemActionCollapse(@NonNull MenuItem item) { return true; } }); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override - public boolean onQueryTextSubmit(String query) { + public boolean onQueryTextSubmit(@NonNull String query) { setSearchFilter(query); return false; } @Override - public boolean onQueryTextChange(String newText) { + public boolean onQueryTextChange(@NonNull String newText) { // when the fragment is recreated this will be called with an empty query // string, causing the existing search query to be lost - work around this // by ignoring the next search performed after recreation From d4bd5e59dd924330f97136ea59d9ad58c14ea7f7 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 18 Aug 2023 14:11:50 +0300 Subject: [PATCH 24/29] Analysis: Add missing n-a to sdk override methods for reader photo vwr FYI: 'n-a' stands for 'nullability annotations'. --- .../android/ui/reader/ReaderPhotoViewerFragment.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPhotoViewerFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPhotoViewerFragment.java index 04e0dbcc0e2d..83e2769b6b87 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPhotoViewerFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPhotoViewerFragment.java @@ -8,6 +8,8 @@ import android.view.View; import android.view.ViewGroup; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import org.wordpress.android.R; @@ -41,7 +43,7 @@ static ReaderPhotoViewerFragment newInstance(String imageUrl, boolean isPrivate) } @Override - public void setArguments(Bundle args) { + public void setArguments(@Nullable Bundle args) { super.setArguments(args); if (args != null) { mImageUrl = args.getString(ReaderConstants.ARG_IMAGE_URL); @@ -49,8 +51,10 @@ public void setArguments(Bundle args) { } } + @Nullable @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.reader_fragment_photo_viewer, container, false); mPhotoView = (ReaderPhotoView) view.findViewById(R.id.photo_view); @@ -64,7 +68,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa @SuppressWarnings("deprecation") @Override - public void onAttach(Activity activity) { + public void onAttach(@NonNull Activity activity) { super.onAttach(activity); if (activity instanceof PhotoViewListener) { mPhotoViewListener = (PhotoViewListener) activity; @@ -78,7 +82,7 @@ public void onResume() { } @Override - public void onSaveInstanceState(Bundle outState) { + public void onSaveInstanceState(@NonNull Bundle outState) { outState.putString(ReaderConstants.ARG_IMAGE_URL, mImageUrl); outState.putBoolean(ReaderConstants.ARG_IS_PRIVATE, mIsPrivate); super.onSaveInstanceState(outState); From 4bc6b3344e34a68c2271b29f67b3f733b2f0a0fe Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 18 Aug 2023 14:19:03 +0300 Subject: [PATCH 25/29] Analysis: Add missing n-a to sdk override methods for reader post list FYI: 'n-a' stands for 'nullability annotations'. --- .../ui/reader/ReaderPostListFragment.java | 66 ++++++++++--------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListFragment.java index 2198cd10cd05..243a4520490a 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListFragment.java @@ -349,7 +349,7 @@ public SiteModel getSelectedSite() { } @Override - public void setArguments(Bundle args) { + public void setArguments(@Nullable Bundle args) { super.setArguments(args); if (args != null) { @@ -378,7 +378,7 @@ public void setArguments(Bundle args) { } @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getActivity().getApplication()).component().inject(this); @@ -846,7 +846,6 @@ private void resumeFollowedSite(Site currentSite) { } @Override - @SuppressWarnings("unchecked") public void onAttach(@NonNull Context context) { super.onAttach(context); @@ -1043,8 +1042,10 @@ private void updatePosts(boolean forced) { } } + @Nullable @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.reader_fragment_post_cards, container, false); mRecyclerView = rootView.findViewById(R.id.reader_recycler_view); @@ -1215,7 +1216,7 @@ private void setupRecyclerToolbar() { mSearchMenuItem.setOnActionExpandListener(new MenuItem.OnActionExpandListener() { @Override - public boolean onMenuItemActionExpand(MenuItem item) { + public boolean onMenuItemActionExpand(@NonNull MenuItem item) { if (getPostListType() != ReaderPostListType.SEARCH_RESULTS) { mReaderTracker.track(AnalyticsTracker.Stat.READER_SEARCH_LOADED); } @@ -1231,27 +1232,26 @@ public boolean onMenuItemActionExpand(MenuItem item) { } @Override - public boolean onMenuItemActionCollapse(MenuItem item) { + public boolean onMenuItemActionCollapse(@NonNull MenuItem item) { requireActivity().finish(); return false; } }); mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { - @Override - public boolean onQueryTextSubmit(String query) { - submitSearchQuery(query); - return true; - } - - @Override - public boolean onQueryTextChange(String newText) { - populateSearchSuggestions(newText); - showSearchMessageOrSuggestions(); - return true; - } - } - ); + @Override + public boolean onQueryTextSubmit(@NonNull String query) { + submitSearchQuery(query); + return true; + } + + @Override + public boolean onQueryTextChange(@NonNull String newText) { + populateSearchSuggestions(newText); + showSearchMessageOrSuggestions(); + return true; + } + }); } private void showSearchMessageOrSuggestions() { @@ -1459,7 +1459,8 @@ private void showSearchTabs() { mSiteSearchAdapterPos = 0; mSearchTabs.addOnTabSelectedListener(new OnTabSelectedListener() { - @Override public void onTabSelected(Tab tab) { + @Override + public void onTabSelected(@NonNull Tab tab) { if (tab.getPosition() == TAB_POSTS) { mRecyclerView.setAdapter(getPostAdapter()); if (mPostSearchAdapterPos > 0) { @@ -1485,7 +1486,8 @@ private void showSearchTabs() { } } - @Override public void onTabUnselected(Tab tab) { + @Override + public void onTabUnselected(@NonNull Tab tab) { if (tab.getPosition() == TAB_POSTS) { mPostSearchAdapterPos = mRecyclerView.getCurrentPosition(); } else if (tab.getPosition() == TAB_SITES) { @@ -1493,7 +1495,8 @@ private void showSearchTabs() { } } - @Override public void onTabReselected(Tab tab) { + @Override + public void onTabReselected(@NonNull Tab tab) { mRecyclerView.smoothScrollToPosition(0); } }); @@ -1781,7 +1784,8 @@ private void setEmptyTitleAndDescriptionForBookmarksList() { mActionableEmptyView.button.setText(R.string.reader_empty_followed_blogs_button_followed); mActionableEmptyView.button.setVisibility(View.VISIBLE); mActionableEmptyView.button.setOnClickListener(new View.OnClickListener() { - @Override public void onClick(View view) { + @Override + public void onClick(@NonNull View v) { setCurrentTagFromEmptyViewButton(ActionableEmptyViewButtonType.FOLLOWED); } }); @@ -1848,7 +1852,8 @@ private void setEmptyTitleDescriptionAndButton(@NonNull String title, String des } mActionableEmptyView.button.setOnClickListener(new View.OnClickListener() { - @Override public void onClick(View view) { + @Override + public void onClick(@NonNull View v) { setCurrentTagFromEmptyViewButton(button); } }); @@ -2444,11 +2449,11 @@ private void hideNewPostsBar() { Animation.AnimationListener listener = new Animation.AnimationListener() { @Override - public void onAnimationStart(Animation animation) { + public void onAnimationStart(@NonNull Animation animation) { } @Override - public void onAnimationEnd(Animation animation) { + public void onAnimationEnd(@NonNull Animation animation) { if (isAdded()) { mNewPostsBar.setVisibility(View.GONE); mIsAnimatingOutNewPostsBar = false; @@ -2456,7 +2461,7 @@ public void onAnimationEnd(Animation animation) { } @Override - public void onAnimationRepeat(Animation animation) { + public void onAnimationRepeat(@NonNull Animation animation) { } }; AniUtils.startAnimation(mNewPostsBar, R.anim.reader_top_bar_out, listener); @@ -2722,7 +2727,8 @@ public void onFollowTapped(View view, String blogName, final long blogId, final Snackbar.LENGTH_LONG ).setAction(getString(R.string.reader_followed_blog_notifications_action), new View.OnClickListener() { - @Override public void onClick(View view) { + @Override + public void onClick(@NonNull View v) { mReaderTracker.trackBlog( AnalyticsTracker.Stat.FOLLOWED_BLOG_NOTIFICATIONS_READER_ENABLED, blogId, @@ -2789,7 +2795,7 @@ public void onScrollToTop() { @Override @SuppressWarnings("deprecation") - public void onActivityResult(int requestCode, int resultCode, Intent data) { + public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RequestCodes.SITE_PICKER && resultCode == Activity.RESULT_OK) { int siteLocalId = data.getIntExtra( From d21db1dbe680c4c6cbb0ff5d0964f434a88900f4 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 18 Aug 2023 14:20:01 +0300 Subject: [PATCH 26/29] Analysis: Add missing n-a to sdk override methods for reader post wvc FYI: 'n-a' stands for 'nullability annotations'. --- .../reader/ReaderPostWebViewCachingFragment.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostWebViewCachingFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostWebViewCachingFragment.java index c9f0b2c40775..f423d84e8227 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostWebViewCachingFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostWebViewCachingFragment.java @@ -7,6 +7,7 @@ import android.view.ViewGroup; import android.webkit.WebView; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; @@ -46,20 +47,23 @@ public static ReaderPostWebViewCachingFragment newInstance(long blogId, long pos return fragment; } - @Override public void onCreate(@Nullable Bundle savedInstanceState) { + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); mBlogId = getArguments().getLong(ARG_BLOG_ID); mPostId = getArguments().getLong(ARG_POST_ID); } - @Nullable @Override - public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { return new ReaderWebView(getActivity()); } @Override - public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); // check network again to detect disconnects during loading + configuration change @@ -69,7 +73,8 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { ((ReaderWebView) view).setIsPrivatePost(post.isPrivate); ((ReaderWebView) view).setBlogSchemeIsHttps(UrlUtils.isHttps(post.getBlogUrl())); ((ReaderWebView) view).setPageFinishedListener(new ReaderWebView.ReaderWebViewPageFinishedListener() { - @Override public void onPageFinished(WebView view, String url) { + @Override + public void onPageFinished(WebView view, String url) { selfRemoveFragment(); } }); From c171a7a300c8ce7c2dff5e0228d0c568218c2335 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 18 Aug 2023 14:20:52 +0300 Subject: [PATCH 27/29] Analysis: Add missing n-a to sdk override methods for reader tag FYI: 'n-a' stands for 'nullability annotations'. --- .../org/wordpress/android/ui/reader/ReaderTagFragment.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderTagFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderTagFragment.java index ee2a37de089f..63cbc6708332 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderTagFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderTagFragment.java @@ -7,6 +7,7 @@ import android.view.ViewGroup; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import org.wordpress.android.R; @@ -29,8 +30,10 @@ static ReaderTagFragment newInstance() { return new ReaderTagFragment(); } + @Nullable @Override - public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.reader_fragment_list, container, false); mRecyclerView = view.findViewById(R.id.recycler_view); return view; @@ -57,7 +60,7 @@ private void checkEmptyView() { @Override @SuppressWarnings("deprecation") - public void onActivityCreated(Bundle savedInstanceState) { + public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mRecyclerView.setAdapter(getTagAdapter()); refresh(); From cdbfd2bf0b0fe9c84f86e46f7fddf164dc2947ad Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 18 Aug 2023 14:22:14 +0300 Subject: [PATCH 28/29] Analysis: Add missing n-a to sdk override methods for stock media rtn FYI: 'n-a' stands for 'nullability annotations'. --- .../android/ui/stockmedia/StockMediaRetainedFragment.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stockmedia/StockMediaRetainedFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/stockmedia/StockMediaRetainedFragment.java index 2610544ff1ee..0f2b2d725630 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stockmedia/StockMediaRetainedFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/stockmedia/StockMediaRetainedFragment.java @@ -52,12 +52,13 @@ int getNextPage() { private StockMediaRetainedData mData; @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true); } - @Nullable StockMediaRetainedData getData() { + @Nullable + StockMediaRetainedData getData() { return mData; } From 164ee6bd66880ab1d7c43399d3efc4040ae3256a Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 18 Aug 2023 14:26:17 +0300 Subject: [PATCH 29/29] Analysis: Add missing n-a to sdk override methods for them browser FYI: 'n-a' stands for 'nullability annotations'. --- .../ui/themes/ThemeBrowserFragment.java | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/themes/ThemeBrowserFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/themes/ThemeBrowserFragment.java index e642eb0fa5e7..c2a7a7d82e25 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/themes/ThemeBrowserFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/themes/ThemeBrowserFragment.java @@ -18,6 +18,7 @@ import android.widget.TextView; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.widget.SearchView; import androidx.fragment.app.Fragment; @@ -111,7 +112,7 @@ interface ThemeBrowserFragmentCallback { @Inject QuickStartUtilsWrapper mQuickStartUtilsWrapper; @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getActivity().getApplication()).component().inject(this); @@ -130,7 +131,7 @@ public void onCreate(Bundle savedInstanceState) { } @Override - public void onAttach(Activity activity) { + public void onAttach(@NonNull Activity activity) { super.onAttach(activity); try { mCallback = (ThemeBrowserFragmentCallback) activity; @@ -148,8 +149,10 @@ public void onDetach() { mCallback = null; } + @Nullable @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.theme_browser_fragment, container, false); mActionableEmptyView = view.findViewById(R.id.actionable_empty_view); @@ -189,7 +192,7 @@ private void showQuickStartFocusPoint() { @Override @SuppressWarnings("deprecation") - public void onActivityCreated(Bundle savedInstanceState) { + public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); getAdapter().setThemeList(fetchThemes()); @@ -206,7 +209,7 @@ public void onSaveInstanceState(@NonNull Bundle outState) { } @Override - public void onCreateOptionsMenu(@NonNull Menu menu, MenuInflater inflater) { + public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) { inflater.inflate(R.menu.search, menu); mSearchMenuItem = menu.findItem(R.id.menu_search); @@ -222,7 +225,7 @@ public void onCreateOptionsMenu(@NonNull Menu menu, MenuInflater inflater) { } @Override - public boolean onOptionsItemSelected(MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { if (item.getItemId() == R.id.menu_search) { AnalyticsUtils.trackWithSiteDetails(AnalyticsTracker.Stat.THEMES_ACCESSED_SEARCH, mSite); return true; @@ -231,7 +234,7 @@ public boolean onOptionsItemSelected(MenuItem item) { } @Override - public boolean onQueryTextSubmit(String query) { + public boolean onQueryTextSubmit(@NonNull String query) { getAdapter().getFilter().filter(query); if (mSearchView != null) { mSearchView.clearFocus(); @@ -240,13 +243,13 @@ public boolean onQueryTextSubmit(String query) { } @Override - public boolean onQueryTextChange(String newText) { + public boolean onQueryTextChange(@NonNull String newText) { getAdapter().getFilter().filter(newText); return true; } @Override - public void onMovedToScrapHeap(View view) { + public void onMovedToScrapHeap(@NonNull View view) { // cancel image fetch requests if the view has been moved to recycler. ImageView niv = view.findViewById(R.id.theme_grid_item_image); if (niv != null) { @@ -476,11 +479,13 @@ private boolean shouldShowPremiumThemes() { } private class ThemeDataSetObserver extends DataSetObserver { - @Override public void onChanged() { + @Override + public void onChanged() { updateDisplay(); } - @Override public void onInvalidated() { + @Override + public void onInvalidated() { updateDisplay(); } }