From 346a8f81bd713805d6c26ba488fdf75a71bc214a Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 10 Aug 2023 16:30:15 +0300 Subject: [PATCH 01/59] Analysis: Add missing n-a to sdk override methods for web view FYI: 'n-a' stands for 'nullability annotations'. --- .../java/org/wordpress/android/ui/WebViewActivity.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/WebViewActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/WebViewActivity.java index cb67fdb3f6f0..30210e2e070b 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/WebViewActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/WebViewActivity.java @@ -7,6 +7,8 @@ import android.webkit.WebView; import androidx.activity.OnBackPressedCallback; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.widget.Toolbar; @@ -29,7 +31,7 @@ public abstract class WebViewActivity extends LocaleAwareActivity { protected WebView mWebView; @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { supportRequestWindowFeature(Window.FEATURE_PROGRESS); super.onCreate(savedInstanceState); @@ -82,7 +84,7 @@ protected void loadContent() { * save the webView state with the bundle so it can be restored */ @Override - protected void onSaveInstanceState(Bundle outState) { + protected void onSaveInstanceState(@NonNull Bundle outState) { mWebView.saveState(outState); super.onSaveInstanceState(outState); } @@ -91,7 +93,7 @@ protected void onSaveInstanceState(Bundle outState) { * restore the webView state saved above */ @Override - protected void onRestoreInstanceState(Bundle savedInstanceState) { + protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); mWebView.restoreState(savedInstanceState); } @@ -161,7 +163,7 @@ public void loadUrl(String url, Map additionalHttpHeaders) { } @Override - public boolean onOptionsItemSelected(final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull final MenuItem item) { if (item.getItemId() == android.R.id.home) { cancel(); finish(); From be358813d2cd0ab36513f8a27f1b004f3ce2d426 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 10 Aug 2023 16:45:27 +0300 Subject: [PATCH 02/59] Analysis: Add missing n-a to sdk override methods for wp web view FYI: 'n-a' stands for 'nullability annotations'. --- .../android/ui/WPWebChromeClientWithFileChooser.java | 7 +++++-- .../org/wordpress/android/ui/WPWebViewActivity.java | 11 ++++++----- .../blaze/blazepromote/BlazePromoteWebViewFragment.kt | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/WPWebChromeClientWithFileChooser.java b/WordPress/src/main/java/org/wordpress/android/ui/WPWebChromeClientWithFileChooser.java index d1cc2ac19ef0..7c4bbb3aa8e2 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/WPWebChromeClientWithFileChooser.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/WPWebChromeClientWithFileChooser.java @@ -10,6 +10,9 @@ import android.webkit.WebView; import android.widget.ProgressBar; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + import org.wordpress.android.fluxc.utils.MediaUtils; import org.wordpress.android.util.AppLog; import org.wordpress.android.util.AppLog.T; @@ -91,7 +94,7 @@ public boolean onShowFileChooser(WebView webView, ValueCallback filePathC return true; } - public void onActivityResult(int requestCode, int resultCode, Intent intent) { + public void onActivityResult(int requestCode, int resultCode, @Nullable Intent intent) { Uri[] selectedUris = null; if (intent != null && resultCode == RESULT_OK && requestCode == WEB_CHROME_CLIENT_FILE_PICKER) { @@ -118,6 +121,6 @@ public void onActivityResult(int requestCode, int resultCode, Intent intent) { } public interface OnShowFileChooserListener { - void startActivityForFileChooserResult(Intent intent, int requestCode); + void startActivityForFileChooserResult(@NonNull Intent intent, int requestCode); } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/WPWebViewActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/WPWebViewActivity.java index 8cac864376ce..8c014b1c45d6 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/WPWebViewActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/WPWebViewActivity.java @@ -22,6 +22,7 @@ import android.widget.TextView; import androidx.activity.OnBackPressedCallback; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.widget.Toolbar; @@ -155,7 +156,7 @@ public class WPWebViewActivity extends WebViewActivity implements ErrorManagedWe private WPWebChromeClientWithFileChooser mWPWebChromeClientWithFileChooser; @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { ((WordPress) getApplication()).component().inject(this); super.onCreate(savedInstanceState); @@ -853,7 +854,7 @@ private boolean isActionableDirectUsage() { } @Override - public boolean onCreateOptionsMenu(Menu menu) { + public boolean onCreateOptionsMenu(@NonNull Menu menu) { super.onCreateOptionsMenu(menu); MenuInflater inflater = getMenuInflater(); @@ -862,7 +863,7 @@ public boolean onCreateOptionsMenu(Menu menu) { } @Override - public boolean onOptionsItemSelected(final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull final MenuItem item) { if (mWebView == null) { return false; } @@ -935,7 +936,7 @@ public void onCookieProgressDialogCancelled() { } @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); if (mWPWebChromeClientWithFileChooser != null) { mWPWebChromeClientWithFileChooser.onActivityResult(requestCode, resultCode, data); @@ -943,7 +944,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { } @Override - public void startActivityForFileChooserResult(Intent intent, int requestCode) { + public void startActivityForFileChooserResult(@NonNull Intent intent, int requestCode) { startActivityForResult(intent, requestCode); } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/blaze/blazepromote/BlazePromoteWebViewFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/blaze/blazepromote/BlazePromoteWebViewFragment.kt index 2910a432d0c2..a3b9d7693101 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/blaze/blazepromote/BlazePromoteWebViewFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/blaze/blazepromote/BlazePromoteWebViewFragment.kt @@ -123,7 +123,7 @@ class BlazePromoteWebViewFragment: Fragment(), OnBlazeWebViewClientListener, } @Suppress("DEPRECATION") - override fun startActivityForFileChooserResult(intent: Intent?, requestCode: Int) { + override fun startActivityForFileChooserResult(intent: Intent, requestCode: Int) { startActivityForResult(intent, requestCode) } From 1ebb78912330f934f63a8e13f52608c18cf5eb5e Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 10 Aug 2023 16:46:39 +0300 Subject: [PATCH 03/59] Analysis: Add missing n-a to sdk override methods for theme web FYI: 'n-a' stands for 'nullability annotations'. --- .../org/wordpress/android/ui/themes/ThemeWebActivity.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/themes/ThemeWebActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/themes/ThemeWebActivity.java index 77c71fac6dd4..a8ea5f98baf9 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/themes/ThemeWebActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/themes/ThemeWebActivity.java @@ -8,6 +8,7 @@ import android.view.MenuItem; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import org.wordpress.android.R; import org.wordpress.android.fluxc.model.SiteModel; @@ -40,7 +41,7 @@ enum ThemeWebActivityType { } @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setActionBarTitleToThemeName(); toggleNavbarVisibility(false); @@ -137,7 +138,7 @@ public static String getUrl(@NonNull SiteModel site, @NonNull ThemeModel theme, } @Override - public boolean onCreateOptionsMenu(Menu menu) { + public boolean onCreateOptionsMenu(@NonNull Menu menu) { if (shouldShowActivateMenuItem()) { getMenuInflater().inflate(R.menu.theme_web, menu); } @@ -145,7 +146,7 @@ public boolean onCreateOptionsMenu(Menu menu) { } @Override - public boolean onOptionsItemSelected(MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { if (item.getItemId() == R.id.action_activate) { Intent returnIntent = new Intent(); setResult(RESULT_OK, returnIntent); From 064b8eefd6cf4a51aadc0a9c912200078ae6cfe9 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 10 Aug 2023 16:49:37 +0300 Subject: [PATCH 04/59] Analysis: Add missing n-a to sdk override methods for jetpack web view FYI: 'n-a' stands for 'nullability annotations'. --- .../ui/JetpackConnectionWebViewActivity.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/JetpackConnectionWebViewActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/JetpackConnectionWebViewActivity.java index 6f9f1759c31f..1bbe56e6cf16 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/JetpackConnectionWebViewActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/JetpackConnectionWebViewActivity.java @@ -8,6 +8,9 @@ import android.webkit.WebView; import android.webkit.WebViewClient; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + import org.wordpress.android.WordPress; import org.wordpress.android.analytics.AnalyticsTracker; import org.wordpress.android.fluxc.model.SiteModel; @@ -81,7 +84,7 @@ private static void startJetpackConnectionFlow(Context context, } @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { mSite = (SiteModel) getIntent().getSerializableExtra(WordPress.SITE); mSource = (JetpackConnectionSource) getIntent().getSerializableExtra(TRACKING_SOURCE_KEY); // We need to get the site before calling super since it'll create the web client @@ -96,7 +99,7 @@ protected WebViewClient createWebViewClient(List allowedURL) { } @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == JETPACK_LOGIN && resultCode == RESULT_OK) { JetpackConnectionWebViewActivity.startJetpackConnectionFlow( @@ -113,19 +116,19 @@ protected void cancel() { } @Override - protected void onSaveInstanceState(Bundle outState) { + protected void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); outState.putString(REDIRECT_PAGE_STATE_ITEM, mWebViewClient.getRedirectPage()); } @Override - protected void onRestoreInstanceState(Bundle savedInstanceState) { + protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); mWebViewClient.setRedirectPage(savedInstanceState.getString(REDIRECT_PAGE_STATE_ITEM)); } @Override - public boolean onCreateOptionsMenu(Menu menu) { + public boolean onCreateOptionsMenu(@NonNull Menu menu) { return true; } From 91a632acab353f168e528964639dd8e4e3bcd549 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 10 Aug 2023 16:52:13 +0300 Subject: [PATCH 05/59] Analysis: Add missing n-a to sdk override methods for ssl certs view FYI: 'n-a' stands for 'nullability annotations'. --- .../org/wordpress/android/networking/SSLCertsViewActivity.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/networking/SSLCertsViewActivity.java b/WordPress/src/main/java/org/wordpress/android/networking/SSLCertsViewActivity.java index 57c67bf8c11e..0ccdfa9452dd 100644 --- a/WordPress/src/main/java/org/wordpress/android/networking/SSLCertsViewActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/networking/SSLCertsViewActivity.java @@ -2,6 +2,7 @@ import android.os.Bundle; +import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import org.wordpress.android.R; @@ -14,7 +15,7 @@ public class SSLCertsViewActivity extends WebViewActivity { public static final String CERT_DETAILS_KEYS = "CertDetails"; @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(getResources().getText(R.string.ssl_certificate_details)); From 2d6457f84fba5863cbbabda0d65dc21488359f32 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 10 Aug 2023 16:55:31 +0300 Subject: [PATCH 06/59] Analysis: Add missing n-a to sdk override methods for add qp shortcut FYI: 'n-a' stands for 'nullability annotations'. --- .../android/ui/AddQuickPressShortcutActivity.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/AddQuickPressShortcutActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/AddQuickPressShortcutActivity.java index b6e3cd7ad806..0074ebc06b72 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/AddQuickPressShortcutActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/AddQuickPressShortcutActivity.java @@ -15,6 +15,8 @@ import android.widget.RelativeLayout; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.widget.Toolbar; @@ -52,7 +54,7 @@ public class AddQuickPressShortcutActivity extends LocaleAwareActivity { @Inject FluxCImageLoader mImageLoader; @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getApplication()).component().inject(this); @@ -69,7 +71,7 @@ public void onCreate(Bundle savedInstanceState) { } @Override - public boolean onOptionsItemSelected(final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull final MenuItem item) { if (item.getItemId() == android.R.id.home) { getOnBackPressedDispatcher().onBackPressed(); return true; @@ -131,7 +133,8 @@ private void buildDialog(final int position) { dialogBuilder.setView(dialogView); dialogBuilder.setPositiveButton(R.string.add, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { + @Override + public void onClick(@Nullable DialogInterface dialog, int which) { if (TextUtils.isEmpty(quickPressShortcutName.getText())) { ToastUtils.showToast(AddQuickPressShortcutActivity.this, R.string.quickpress_add_error, ToastUtils.Duration.LONG); @@ -162,7 +165,8 @@ public void onClick(DialogInterface dialog, int which) { }); dialogBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { // just let the dialog close - public void onClick(DialogInterface dialog, int which) { + @Override + public void onClick(@Nullable DialogInterface dialog, int which) { } }); @@ -171,7 +175,7 @@ public void onClick(DialogInterface dialog, int which) { } @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case RequestCodes.ADD_ACCOUNT: From e31f05615345edfaf3acf6d3966358fd4d4a0c98 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 10 Aug 2023 16:59:32 +0300 Subject: [PATCH 07/59] Analysis: Add missing n-a to sdk override methods for app log viewer FYI: 'n-a' stands for 'nullability annotations'. --- .../org/wordpress/android/ui/AppLogViewerActivity.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/AppLogViewerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/AppLogViewerActivity.java index a9110642bda7..28365039b260 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/AppLogViewerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/AppLogViewerActivity.java @@ -15,6 +15,8 @@ import android.widget.ListView; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.widget.Toolbar; import androidx.core.text.HtmlCompat; @@ -34,7 +36,7 @@ */ public class AppLogViewerActivity extends LocaleAwareActivity { @Override - protected void onCreate(Bundle savedInstanceState) { + protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.logviewer_activity); @@ -76,7 +78,7 @@ public long getItemId(int position) { } @Override - public View getView(int position, View convertView, ViewGroup parent) { + public View getView(int position, @Nullable View convertView, @Nullable ViewGroup parent) { final LogViewHolder holder; if (convertView == null) { convertView = mInflater.inflate(R.layout.logviewer_listitem, parent, false); @@ -136,7 +138,7 @@ private void copyAppLogToClipboard() { } @Override - public boolean onCreateOptionsMenu(Menu menu) { + public boolean onCreateOptionsMenu(@NonNull Menu menu) { super.onCreateOptionsMenu(menu); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.app_log_viewer_menu, menu); @@ -144,7 +146,7 @@ public boolean onCreateOptionsMenu(Menu menu) { } @Override - public boolean onOptionsItemSelected(final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull final MenuItem item) { switch (item.getItemId()) { case android.R.id.home: finish(); From c035d761d12c50da362d284269bba91b67844edf Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 10 Aug 2023 17:07:08 +0300 Subject: [PATCH 08/59] Analysis: Suppress non constant res id lint warning for app log viewer Warning Message: "Resource IDs will be non-final by default in Android Gradle Plugin version 8.0, avoid using them in const fields" Explanation: "Avoid the usage of resource IDs where constant expressions are required. A future version of the Android Gradle Plugin will generate R classes with non-constant IDs in order to improve the performance of incremental compilation." ------------------------------------------------------------------------ This Lint warning is suppressed, that is, instead of it being resolved, since a resolution would require a proper investigation. As such, it might be best to ignore this as out of scope, for now, and so as to not introduce any breaking changes with this upgrade overall. Related Commit: f8bc363cf39c000216b53bc8e910b00f5b6e1a89 --- .../java/org/wordpress/android/ui/AppLogViewerActivity.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/AppLogViewerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/AppLogViewerActivity.java index 28365039b260..4c9e336f4cdd 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/AppLogViewerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/AppLogViewerActivity.java @@ -1,5 +1,6 @@ package org.wordpress.android.ui; +import android.annotation.SuppressLint; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; @@ -146,6 +147,7 @@ public boolean onCreateOptionsMenu(@NonNull Menu menu) { } @Override + @SuppressLint("NonConstantResourceId") public boolean onOptionsItemSelected(@NonNull final MenuItem item) { switch (item.getItemId()) { case android.R.id.home: From adb1e7ff0ecaa6f6b934b6704eef1df1d5b5cd55 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 10 Aug 2023 17:11:33 +0300 Subject: [PATCH 09/59] Analysis: Add missing n-a to sdk override methods for jetpack connection FYI: 'n-a' stands for 'nullability annotations'. --- .../android/ui/JetpackConnectionResultActivity.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/JetpackConnectionResultActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/JetpackConnectionResultActivity.java index 93dc0b76cc6f..10ba186184a9 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/JetpackConnectionResultActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/JetpackConnectionResultActivity.java @@ -6,6 +6,7 @@ import android.text.TextUtils; import androidx.activity.OnBackPressedCallback; +import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.widget.Toolbar; @@ -50,7 +51,7 @@ public class JetpackConnectionResultActivity extends LocaleAwareActivity { @Inject Dispatcher mDispatcher; @Override - protected void onCreate(Bundle savedInstanceState) { + protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getApplication()).component().inject(this); @@ -109,7 +110,7 @@ public void handleOnBackPressed() { } @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RequestCodes.JETPACK_LOGIN) { if (resultCode == RESULT_OK) { From 56febf44e8099c0795a25361f070fefdeea28fc1 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 10 Aug 2023 17:16:41 +0300 Subject: [PATCH 10/59] Analysis: Add missing n-a to sdk override methods for share receiver FYI: 'n-a' stands for 'nullability annotations'. --- .../android/ui/ShareIntentReceiverActivity.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/ShareIntentReceiverActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/ShareIntentReceiverActivity.java index f8ba7ecc33d1..79a7c37c97d8 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/ShareIntentReceiverActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/ShareIntentReceiverActivity.java @@ -7,6 +7,7 @@ import android.widget.Toast; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.core.app.TaskStackBuilder; import androidx.preference.PreferenceManager; @@ -56,14 +57,14 @@ public class ShareIntentReceiverActivity extends LocaleAwareActivity implements private ArrayList mLocalMediaUris = new ArrayList<>(); @Override - protected void onNewIntent(Intent intent) { + protected void onNewIntent(@NonNull Intent intent) { super.onNewIntent(intent); setIntent(intent); refreshContent(); } @Override - protected void onCreate(Bundle savedInstanceState) { + protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getApplication()).component().inject(this); setContentView(R.layout.share_intent_receiver_activity); @@ -123,7 +124,7 @@ private void loadState(Bundle savedInstanceState) { } @Override - public void onSaveInstanceState(Bundle outState) { + public void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(KEY_SELECTED_SITE_LOCAL_ID, mClickedSiteLocalId); outState.putString(KEY_SHARE_ACTION_ID, mShareActionName); @@ -136,7 +137,7 @@ private int loadLastUsedBlogLocalId() { } @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RequestCodes.DO_LOGIN) { if (resultCode == RESULT_OK) { From 4737bfb588aae7dbae3833ad327205214169793c Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 10 Aug 2023 17:20:50 +0300 Subject: [PATCH 11/59] Analysis: Add missing n-a to sdk override methods for login FYI: 'n-a' stands for 'nullability annotations'. --- .../org/wordpress/android/ui/accounts/LoginActivity.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginActivity.java index 0af19dbb7cd7..c98b03d4e58f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginActivity.java @@ -140,7 +140,7 @@ private enum SmartLockHelperState { @Inject LandingScreenRevampFeatureConfig mLandingScreenRevampFeatureConfig; @Override - protected void onCreate(Bundle savedInstanceState) { + protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); LoginFlowThemeHelper.injectMissingCustomAttributes(getTheme()); @@ -239,7 +239,7 @@ private void loginFromPrologue() { } @Override - public void onSaveInstanceState(Bundle outState) { + public void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); outState.putString(KEY_SMARTLOCK_HELPER_STATE, mSmartLockHelperState.name()); outState.putBoolean(KEY_SIGNUP_FROM_LOGIN_ENABLED, mIsSignupFromLoginEnabled); @@ -291,7 +291,7 @@ private LoginEmailFragment getLoginEmailFragment() { } @Override - public boolean onOptionsItemSelected(MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { if (item.getItemId() == android.R.id.home) { getOnBackPressedDispatcher().onBackPressed(); return true; @@ -366,7 +366,7 @@ private void loggedInAndFinish(ArrayList oldSitesIds, boolean doLoginUp } @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { AppLog.d(T.MAIN, "LoginActivity: onActivity Result - requestCode" + requestCode); super.onActivityResult(requestCode, resultCode, data); From dfefa3b3680f0260ed914c04970eede3e0df673e Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 10 Aug 2023 17:21:53 +0300 Subject: [PATCH 12/59] Analysis: Add missing n-a to sdk override methods for login epilogue FYI: 'n-a' stands for 'nullability annotations'. --- .../wordpress/android/ui/accounts/LoginEpilogueActivity.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginEpilogueActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginEpilogueActivity.java index 8e31fe1a8e60..3ad74c934e1b 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginEpilogueActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginEpilogueActivity.java @@ -3,6 +3,7 @@ import android.content.Intent; import android.os.Bundle; +import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentTransaction; import androidx.lifecycle.ViewModelProvider; @@ -46,7 +47,7 @@ public class LoginEpilogueActivity extends LocaleAwareActivity implements LoginE @Inject LoginEpilogueViewModel mViewModel; @Override - protected void onCreate(Bundle savedInstanceState) { + protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); LoginFlowThemeHelper.injectMissingCustomAttributes(getTheme()); @@ -159,7 +160,7 @@ private void showJetpackIndividualPluginOverlay() { } @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RequestCodes.CREATE_SITE && resultCode == RESULT_OK From 7f4cbaa549f1c591ddb9c31b2cb6ad38b931548c Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 10 Aug 2023 17:22:41 +0300 Subject: [PATCH 13/59] Analysis: Add missing n-a to sdk override methods for login magic link FYI: 'n-a' stands for 'nullability annotations'. --- .../android/ui/accounts/LoginMagicLinkInterceptActivity.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginMagicLinkInterceptActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginMagicLinkInterceptActivity.java index 90a8006dfebf..b9c04c8eb213 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginMagicLinkInterceptActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginMagicLinkInterceptActivity.java @@ -4,6 +4,8 @@ import android.net.Uri; import android.os.Bundle; +import androidx.annotation.Nullable; + import org.wordpress.android.login.LoginAnalyticsListener; import org.wordpress.android.ui.JetpackConnectionSource; import org.wordpress.android.ui.LocaleAwareActivity; @@ -29,7 +31,7 @@ public class LoginMagicLinkInterceptActivity extends LocaleAwareActivity { @Inject protected LoginAnalyticsListener mLoginAnalyticsListener; @Override - protected void onCreate(Bundle savedInstanceState) { + protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); mAction = getIntent().getAction(); From 4e9a2c1989a76c6f15be40952e5897dc0731b373 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 10 Aug 2023 17:23:17 +0300 Subject: [PATCH 14/59] Analysis: Add missing n-a to sdk override methods for signup epilogue FYI: 'n-a' stands for 'nullability annotations'. --- .../wordpress/android/ui/accounts/SignupEpilogueActivity.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/SignupEpilogueActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/accounts/SignupEpilogueActivity.java index f156effdb53e..12992ae5e703 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/SignupEpilogueActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/SignupEpilogueActivity.java @@ -2,6 +2,7 @@ import android.os.Bundle; +import androidx.annotation.Nullable; import androidx.fragment.app.FragmentTransaction; import org.wordpress.android.R; @@ -28,7 +29,7 @@ public class SignupEpilogueActivity extends LocaleAwareActivity implements Signu @Inject SiteStore mSiteStore; @Override - protected void onCreate(Bundle savedInstanceState) { + protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); LoginFlowThemeHelper.injectMissingCustomAttributes(getTheme()); From a0da7cd138cbb8abe709dfdb86828a504f9e7455 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 10 Aug 2023 17:24:49 +0300 Subject: [PATCH 15/59] Analysis: Add missing n-a to sdk override methods for comments detail FYI: 'n-a' stands for 'nullability annotations'. --- .../android/ui/comments/CommentsDetailActivity.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentsDetailActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentsDetailActivity.java index f831d976dc20..0cb1509b112e 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentsDetailActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentsDetailActivity.java @@ -9,6 +9,8 @@ import android.widget.ProgressBar; import androidx.activity.OnBackPressedCallback; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.widget.Toolbar; import androidx.viewpager.widget.ViewPager; @@ -79,7 +81,7 @@ public class CommentsDetailActivity extends LocaleAwareActivity private boolean mCanLoadMoreComments = true; @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); mCommentsStoreAdapter.register(this); AppLog.i(AppLog.T.COMMENTS, "Creating CommentsDetailActivity"); @@ -138,7 +140,7 @@ public void handleOnBackPressed() { } @Override - protected void onSaveInstanceState(Bundle outState) { + protected void onSaveInstanceState(@NonNull Bundle outState) { outState.putLong(COMMENT_ID_EXTRA, mCommentId); outState.putSerializable(WordPress.SITE, mSite); outState.putSerializable(COMMENT_STATUS_FILTER_EXTRA, mStatusFilter); @@ -152,7 +154,7 @@ public void onDestroy() { } @Override - public boolean onOptionsItemSelected(MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { if (item.getItemId() == android.R.id.home) { finish(); return true; From 3e92a6d761ce6214622c411328747fd54801bc29 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 10 Aug 2023 17:27:41 +0300 Subject: [PATCH 16/59] Analysis: Add missing n-a to sdk override methods for edit comment FYI: 'n-a' stands for 'nullability annotations'. --- .../ui/comments/EditCommentActivity.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/comments/EditCommentActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/comments/EditCommentActivity.java index b18baf91e594..497091150082 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/comments/EditCommentActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/comments/EditCommentActivity.java @@ -15,6 +15,7 @@ import androidx.activity.OnBackPressedCallback; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.widget.Toolbar; @@ -70,8 +71,8 @@ public class EditCommentActivity extends LocaleAwareActivity { @Inject SiteStore mSiteStore; @Override - public void onCreate(Bundle icicle) { - super.onCreate(icicle); + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); ((WordPress) getApplication()).component().inject(this); setContentView(R.layout.comment_edit_activity); @@ -98,8 +99,8 @@ public void handleOnBackPressed() { loadComment(getIntent()); - if (icicle != null) { - if (icicle.getBoolean(ARG_CANCEL_EDITING_COMMENT_DIALOG_VISIBLE, false)) { + if (savedInstanceState != null) { + if (savedInstanceState.getBoolean(ARG_CANCEL_EDITING_COMMENT_DIALOG_VISIBLE, false)) { cancelEditCommentConfirmation(); } } @@ -177,17 +178,17 @@ private void configureViews() { // show error when comment content is empty editContent.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) { boolean hasError = (editContent.getError() != null); - boolean hasText = (s != null && s.length() > 0); + boolean hasText = s.length() > 0; if (!hasText && !hasError) { editContent.setError(getString(R.string.content_required)); } else if (hasText && hasError) { @@ -198,7 +199,7 @@ public void afterTextChanged(Editable s) { } @Override - public boolean onCreateOptionsMenu(Menu menu) { + public boolean onCreateOptionsMenu(@NonNull Menu menu) { super.onCreateOptionsMenu(menu); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.edit_comment, menu); @@ -206,7 +207,7 @@ public boolean onCreateOptionsMenu(Menu menu) { } @Override - public boolean onOptionsItemSelected(final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull final MenuItem item) { int i = item.getItemId(); if (i == android.R.id.home) { getOnBackPressedDispatcher().onBackPressed(); @@ -260,6 +261,7 @@ private boolean isCommentEdited() { return !content.equals(mComment.getContent()); } + @Nullable @Override @SuppressWarnings("deprecation") protected Dialog onCreateDialog(int id) { From 8a38d8c682e5cbd5eb5f72053dca9beb4af85cbc Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 11 Aug 2023 13:53:55 +0300 Subject: [PATCH 17/59] Analysis: Add missing n-a to sdk override methods for deep linking FYI: 'n-a' stands for 'nullability annotations'. --- .../ui/deeplinks/DeepLinkingIntentReceiverActivity.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/deeplinks/DeepLinkingIntentReceiverActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/deeplinks/DeepLinkingIntentReceiverActivity.java index 28066e7cf893..b4ac99c58b2b 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/deeplinks/DeepLinkingIntentReceiverActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/deeplinks/DeepLinkingIntentReceiverActivity.java @@ -6,6 +6,7 @@ import androidx.activity.OnBackPressedCallback; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.lifecycle.ViewModelProvider; import org.wordpress.android.ui.ActivityLauncherWrapper; @@ -49,7 +50,7 @@ public class DeepLinkingIntentReceiverActivity extends LocaleAwareActivity { private JetpackFeatureFullScreenOverlayViewModel mJetpackFullScreenViewModel; @Override - protected void onCreate(Bundle savedInstanceState) { + protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); OnBackPressedCallback callback = new OnBackPressedCallback(true) { @@ -142,7 +143,7 @@ private DeepLinkEntryPoint extractEntryPoint(Intent intent) { } @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); // show the post if user is returning from successful login if (requestCode == RequestCodes.DO_LOGIN && resultCode == RESULT_OK) { From 88d274fded462b26adeeade387bb85b5e7ffc164 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 11 Aug 2023 14:34:02 +0300 Subject: [PATCH 18/59] Analysis: Add missing n-a to sdk override methods for site picker FYI: 'n-a' stands for 'nullability annotations'. --- .../android/ui/main/SitePickerActivity.java | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java index 96f1d84f00f7..9cf20b075509 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java @@ -11,6 +11,7 @@ import android.widget.ArrayAdapter; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.view.ActionMode; import androidx.appcompat.widget.SearchView; @@ -141,7 +142,7 @@ public class SitePickerActivity extends LocaleAwareActivity @Inject WPIndividualPluginOverlayFeatureConfig mWPIndividualPluginOverlayFeatureConfig; @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewModel = new ViewModelProvider(this, mViewModelFactory).get(SitePickerViewModel.class); @@ -224,7 +225,7 @@ public void onResume() { } @Override - protected void onSaveInstanceState(Bundle outState) { + protected void onSaveInstanceState(@NonNull Bundle outState) { outState.putInt(KEY_SITE_LOCAL_ID, mCurrentLocalId); outState.putBoolean(KEY_IS_IN_SEARCH_MODE, getAdapter().getIsInSearchMode()); outState.putString(KEY_LAST_SEARCH, getAdapter().getLastSearch()); @@ -240,7 +241,7 @@ protected void onSaveInstanceState(Bundle outState) { } @Override - public boolean onCreateOptionsMenu(Menu menu) { + public boolean onCreateOptionsMenu(@NonNull Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.site_picker, menu); mMenuSearch = menu.findItem(R.id.menu_search); @@ -250,7 +251,7 @@ public boolean onCreateOptionsMenu(Menu menu) { } @Override - public boolean onPrepareOptionsMenu(Menu menu) { + public boolean onPrepareOptionsMenu(@NonNull Menu menu) { super.onPrepareOptionsMenu(menu); updateMenuItemVisibility(); setupSearchView(); @@ -278,7 +279,7 @@ private void updateMenuItemVisibility() { } @Override - public boolean onOptionsItemSelected(final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull final MenuItem item) { int itemId = item.getItemId(); if (itemId == android.R.id.home) { AnalyticsTracker.track(Stat.SITE_SWITCHER_DISMISSED); @@ -300,7 +301,7 @@ public boolean onOptionsItemSelected(final MenuItem item) { } @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { @@ -575,7 +576,7 @@ private void setupSearchView() { mMenuSearch.setOnActionExpandListener(new MenuItem.OnActionExpandListener() { @Override - public boolean onMenuItemActionExpand(MenuItem item) { + public boolean onMenuItemActionExpand(@NonNull MenuItem item) { if (!getAdapter().getIsInSearchMode()) { enableSearchMode(); mMenuEdit.setVisible(false); @@ -588,7 +589,7 @@ public boolean onMenuItemActionExpand(MenuItem item) { } @Override - public boolean onMenuItemActionCollapse(MenuItem item) { + public boolean onMenuItemActionCollapse(@NonNull MenuItem item) { disableSearchMode(); mSearchView.setOnQueryTextListener(null); return true; @@ -663,13 +664,13 @@ public void onSiteClick(SiteRecord siteRecord) { } @Override - public boolean onQueryTextSubmit(String s) { + public boolean onQueryTextSubmit(@NonNull String s) { hideSoftKeyboard(); return true; } @Override - public boolean onQueryTextChange(String s) { + public boolean onQueryTextChange(@NonNull String s) { if (getAdapter().getIsInSearchMode()) { AnalyticsTracker.track(Stat.SITE_SWITCHER_SEARCH_PERFORMED); getAdapter().setLastSearch(s); @@ -696,19 +697,19 @@ private void selectSiteAndFinish(SiteRecord siteRecord) { private final class ReblogActionModeCallback implements ActionMode.Callback { @Override - public boolean onCreateActionMode(ActionMode mode, Menu menu) { + public boolean onCreateActionMode(@NonNull ActionMode mode, @NonNull Menu menu) { mReblogActionMode = mode; mode.getMenuInflater().inflate(R.menu.site_picker_reblog_action_mode, menu); return true; } @Override - public boolean onPrepareActionMode(ActionMode mode, Menu menu) { + public boolean onPrepareActionMode(@NonNull ActionMode mode, @NonNull Menu menu) { return true; } @Override - public boolean onActionItemClicked(ActionMode mode, MenuItem item) { + public boolean onActionItemClicked(@NonNull ActionMode mode, @NonNull MenuItem item) { int itemId = item.getItemId(); if (itemId == R.id.continue_flow) { @@ -719,7 +720,7 @@ public boolean onActionItemClicked(ActionMode mode, MenuItem item) { } @Override - public void onDestroyActionMode(ActionMode mode) { + public void onDestroyActionMode(@NonNull ActionMode mode) { mViewModel.onReblogActionBackSelected(); mReblogActionMode = null; } @@ -730,7 +731,7 @@ private final class ActionModeCallback implements ActionMode.Callback { private Set mChangeSet; @Override - public boolean onCreateActionMode(ActionMode actionMode, Menu menu) { + public boolean onCreateActionMode(@NonNull ActionMode actionMode, @NonNull Menu menu) { mActionMode = actionMode; mHasChanges = false; mChangeSet = new HashSet<>(); @@ -740,7 +741,7 @@ public boolean onCreateActionMode(ActionMode actionMode, Menu menu) { } @Override - public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) { + public boolean onPrepareActionMode(@NonNull ActionMode actionMode, @NonNull Menu menu) { MenuItem mnuShow = menu.findItem(R.id.menu_show); mnuShow.setEnabled(mShowMenuEnabled); @@ -757,7 +758,7 @@ public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) { } @Override - public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) { + public boolean onActionItemClicked(@NonNull ActionMode actionMode, @NonNull MenuItem menuItem) { int itemId = menuItem.getItemId(); if (itemId == R.id.menu_show) { Set changeSet = getAdapter().setVisibilityForSelectedSites(true); @@ -778,7 +779,7 @@ public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) { } @Override - public void onDestroyActionMode(ActionMode actionMode) { + public void onDestroyActionMode(@NonNull ActionMode actionMode) { if (mHasChanges) { saveSitesVisibility(mChangeSet); } @@ -823,7 +824,7 @@ public static class AddSiteDialog extends DialogFragment { @NonNull @Override - public Dialog onCreateDialog(Bundle savedInstanceState) { + public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { SiteCreationSource source = SiteCreationSource.fromString(getArguments().getString(ARG_SITE_CREATION_SOURCE)); CharSequence[] items = From 2b54a8ba694c40ec8cc300bbe86ed21af3cd558e Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 11 Aug 2023 15:17:28 +0300 Subject: [PATCH 19/59] Analysis: Add missing n-a to sdk override methods for wp main FYI: 'n-a' stands for 'nullability annotations'. --- .../wordpress/android/ui/main/WPMainActivity.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java index 0ee94a80626c..e955c947fec3 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java @@ -306,7 +306,7 @@ public interface OnActivityBackPressedListener { }; @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { ProfilingUtils.split("WPMainActivity.onCreate"); ((WordPress) getApplication()).component().inject(this); @@ -842,7 +842,7 @@ private CreatePageDashboardSource getCreatePageDashboardSourceFromActionType(Act } @Override - protected void onNewIntent(Intent intent) { + protected void onNewIntent(@NonNull Intent intent) { super.onNewIntent(intent); setIntent(intent); AppLog.i(T.MAIN, "main activity > new intent"); @@ -1311,7 +1311,7 @@ private void setSite(Intent data) { @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 (!mSelectedSiteRepository.hasSelectedSite()) { initSelectedSite(); @@ -1344,7 +1344,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { mUploadActionUseCase.getUploadAction(post), new View.OnClickListener() { @Override - public void onClick(View v) { + public void onClick(@NonNull View v) { UploadUtils.publishPost(WPMainActivity.this, post, site, mDispatcher); } }, @@ -1851,11 +1851,13 @@ public void onSetPromptReminderClick(final int siteId) { mBloggingRemindersViewModel.onBloggingPromptSchedulingRequested(siteId); } - @Override public void onShowBloggingPromptsOnboarding() { + @Override + public void onShowBloggingPromptsOnboarding() { showBloggingPromptsOnboarding(); } - @Override public void onUpdateSelectedSiteResult(int resultCode, @Nullable Intent data) { + @Override + public void onUpdateSelectedSiteResult(int resultCode, @Nullable Intent data) { onActivityResult(RequestCodes.SITE_PICKER, resultCode, data); } From 7a7fc66f7b62a9d68da2276672b393050307e07b Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 11 Aug 2023 15:30:46 +0300 Subject: [PATCH 20/59] Analysis: Add missing n-a to sdk override methods for media browser FYI: 'n-a' stands for 'nullability annotations'. --- .../ui/media/MediaBrowserActivity.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java index 7182f374df77..16c3ef0d8fe0 100755 --- a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java @@ -160,7 +160,7 @@ private enum AddMenuItem { } @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getApplication()).component().inject(this); @@ -241,7 +241,8 @@ public void onCreate(Bundle savedInstanceState) { showQuota(true); } - @Override protected void onNewIntent(Intent intent) { + @Override + protected void onNewIntent(@NonNull Intent intent) { super.onNewIntent(intent); if (intent.hasExtra(ARG_NOTIFICATION_TYPE)) { @@ -328,15 +329,15 @@ private void setupTabs() { mTabLayout.clearOnTabSelectedListeners(); mTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { @Override - public void onTabSelected(TabLayout.Tab tab) { + public void onTabSelected(@NonNull TabLayout.Tab tab) { setFilter(getFilterForPosition(tab.getPosition())); } @Override - public void onTabUnselected(TabLayout.Tab tab) { + public void onTabUnselected(@NonNull TabLayout.Tab tab) { // noop } @Override - public void onTabReselected(TabLayout.Tab tab) { + public void onTabReselected(@NonNull TabLayout.Tab tab) { setFilter(getFilterForPosition(tab.getPosition())); } }); @@ -493,7 +494,7 @@ private void checkRecordedVideoDurationBeforeUploadAndTrack() { } @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); switch (requestCode) { @@ -596,7 +597,7 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis } @Override - public boolean onCreateOptionsMenu(Menu menu) { + public boolean onCreateOptionsMenu(@NonNull Menu menu) { mMenu = menu; getMenuInflater().inflate(R.menu.media_browser, menu); @@ -636,7 +637,7 @@ public boolean onCreateOptionsMenu(Menu menu) { } @Override - public boolean onOptionsItemSelected(MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case android.R.id.home: getOnBackPressedDispatcher().onBackPressed(); @@ -664,7 +665,7 @@ public boolean onOptionsItemSelected(MenuItem item) { } @Override - public boolean onMenuItemActionExpand(MenuItem item) { + public boolean onMenuItemActionExpand(@NonNull MenuItem item) { mMenu.findItem(R.id.menu_new_media).setVisible(false); mMediaGridFragment.showActionableEmptyViewButton(false); @@ -680,7 +681,7 @@ public boolean onMenuItemActionExpand(MenuItem item) { } @Override - public boolean onMenuItemActionCollapse(MenuItem item) { + public boolean onMenuItemActionCollapse(@NonNull MenuItem item) { mMenu.findItem(R.id.menu_new_media).setVisible(true); mMediaGridFragment.showActionableEmptyViewButton(true); invalidateOptionsMenu(); @@ -692,7 +693,7 @@ public boolean onMenuItemActionCollapse(MenuItem item) { } @Override - public boolean onQueryTextSubmit(String query) { + public boolean onQueryTextSubmit(@NonNull String query) { if (mMediaGridFragment != null) { mMediaGridFragment.search(query); } @@ -704,7 +705,7 @@ public boolean onQueryTextSubmit(String query) { } @Override - public boolean onQueryTextChange(String newText) { + public boolean onQueryTextChange(@NonNull String newText) { if (mMediaGridFragment != null) { mMediaGridFragment.search(newText); } @@ -936,7 +937,7 @@ public void onServiceDisconnected(ComponentName arg0) { private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override - public void onReceive(Context context, Intent intent) { + public void onReceive(@NonNull Context context, @NonNull Intent intent) { if (ConnectivityManager.CONNECTIVITY_ACTION.equals(intent.getAction())) { // Coming from zero connection. Continue what's pending for delete if (mMediaStore.hasSiteMediaToDelete(mSite)) { From 3588f844a545ef620fd5fd3beaf4c8fa09391c7d Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 11 Aug 2023 16:02:49 +0300 Subject: [PATCH 21/59] Analysis: Suppress non constant res id lint warning for media browser Warning Message: "Resource IDs will be non-final by default in Android Gradle Plugin version 8.0, avoid using them in const fields" Explanation: "Avoid the usage of resource IDs where constant expressions are required. A future version of the Android Gradle Plugin will generate R classes with non-constant IDs in order to improve the performance of incremental compilation." ------------------------------------------------------------------------ This Lint warning is suppressed, that is, instead of it being resolved, since a resolution would require a proper investigation. As such, it might be best to ignore this as out of scope, for now, and so as to not introduce any breaking changes with this upgrade overall. Related Commit: f8bc363cf39c000216b53bc8e910b00f5b6e1a89 --- .../org/wordpress/android/ui/media/MediaBrowserActivity.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java index 16c3ef0d8fe0..0e1081cfdd54 100755 --- a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java @@ -1,6 +1,7 @@ package org.wordpress.android.ui.media; import android.Manifest; +import android.annotation.SuppressLint; import android.app.Activity; import android.content.BroadcastReceiver; import android.content.ComponentName; @@ -637,6 +638,7 @@ public boolean onCreateOptionsMenu(@NonNull Menu menu) { } @Override + @SuppressLint("NonConstantResourceId") public boolean onOptionsItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case android.R.id.home: From 4152299b67be04999e20384c6c196c7c3ac9bbf0 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 11 Aug 2023 16:06:42 +0300 Subject: [PATCH 22/59] Analysis: Add missing n-a to sdk override methods for media preview FYI: 'n-a' stands for 'nullability annotations'. --- .../ui/media/MediaPreviewActivity.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaPreviewActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaPreviewActivity.java index 5f3a70a4f110..edc4570a5985 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaPreviewActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaPreviewActivity.java @@ -220,7 +220,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { } @Override - public boolean onOptionsItemSelected(MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { if (item.getItemId() == android.R.id.home) { getOnBackPressedDispatcher().onBackPressed(); return true; @@ -235,7 +235,7 @@ public void finish() { } @Override - protected void onSaveInstanceState(Bundle outState) { + protected void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); outState.putSerializable(WordPress.SITE, mSite); outState.putInt(MediaPreviewFragment.ARG_MEDIA_ID, mMediaId); @@ -282,16 +282,16 @@ public void run() { if (!isFinishing() && mToolbar.getVisibility() == View.VISIBLE) { AniUtils.startAnimation(mToolbar, R.anim.toolbar_fade_out_and_up, 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) { mToolbar.setVisibility(View.GONE); } @Override - public void onAnimationRepeat(Animation animation) { + public void onAnimationRepeat(@NonNull Animation animation) { } }); } @@ -317,16 +317,16 @@ private void showToolbar() { if (mToolbar.getVisibility() != View.VISIBLE) { AniUtils.startAnimation(mToolbar, R.anim.toolbar_fade_in_and_down, new Animation.AnimationListener() { @Override - public void onAnimationStart(Animation animation) { + public void onAnimationStart(@NonNull Animation animation) { mToolbar.setVisibility(View.VISIBLE); } @Override - public void onAnimationEnd(Animation animation) { + public void onAnimationEnd(@NonNull Animation animation) { } @Override - public void onAnimationRepeat(Animation animation) { + public void onAnimationRepeat(@NonNull Animation animation) { } }); } @@ -392,6 +392,7 @@ class MediaPagerAdapter extends FragmentStatePagerAdapter { super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT); } + @NonNull @Override public Fragment getItem(int position) { MediaPreviewFragment fragment; @@ -429,7 +430,7 @@ public int getCount() { @NonNull @Override - public Object instantiateItem(ViewGroup container, int position) { + public Object instantiateItem(@NonNull ViewGroup container, int position) { Object item = super.instantiateItem(container, position); if (item instanceof Fragment) { mFragmentMap.put(position, (Fragment) item); @@ -438,13 +439,13 @@ public Object instantiateItem(ViewGroup container, int position) { } @Override - public void destroyItem(ViewGroup container, int position, Object object) { + public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) { mFragmentMap.remove(position); super.destroyItem(container, position, object); } @Override - public void restoreState(Parcelable state, ClassLoader loader) { + public void restoreState(@Nullable Parcelable state, @Nullable ClassLoader loader) { // work around https://code.google.com/p/android/issues/detail?id=42601 try { super.restoreState(state, loader); From 77532648c183121d5a782e23afdb1b4b5b829308 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 11 Aug 2023 16:14:49 +0300 Subject: [PATCH 23/59] Analysis: Add missing n-a to sdk override methods for media settings FYI: 'n-a' stands for 'nullability annotations'. --- .../ui/media/MediaSettingsActivity.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaSettingsActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaSettingsActivity.java index 362516305a6e..b4b211017bf1 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaSettingsActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaSettingsActivity.java @@ -297,8 +297,8 @@ public void handleOnBackPressed() { int mScrollRange = -1; @Override - public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { - if (mScrollRange == -1) { + public void onOffsetChanged(@Nullable AppBarLayout appBarLayout, int verticalOffset) { + if (mScrollRange == -1 && appBarLayout != null) { mScrollRange = appBarLayout.getTotalScrollRange(); } if (mScrollRange + verticalOffset == 0) { @@ -526,13 +526,13 @@ private void showProgress(boolean show) { } @Override - public boolean onCreateOptionsMenu(Menu menu) { + public boolean onCreateOptionsMenu(@NonNull Menu menu) { getMenuInflater().inflate(R.menu.media_settings, menu); return super.onCreateOptionsMenu(menu); } @Override - public boolean onPrepareOptionsMenu(Menu menu) { + public boolean onPrepareOptionsMenu(@NonNull Menu menu) { boolean showSaveMenu = mSite != null && !mSite.isPrivate() && !isMediaFromEditor(); boolean showShareMenu = mSite != null && !mSite.isPrivate() && !isMediaFromEditor(); boolean showTrashMenu = mSite != null && !isMediaFromEditor(); @@ -555,7 +555,7 @@ public boolean onPrepareOptionsMenu(Menu menu) { } @Override - public boolean onOptionsItemSelected(MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { if (item.getItemId() == android.R.id.home) { getOnBackPressedDispatcher().onBackPressed(); return true; @@ -676,15 +676,15 @@ private void setupImageSizeSeekBar() { mImageSizeSeekBarView.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override - public void onStopTrackingTouch(SeekBar seekBar) { + public void onStopTrackingTouch(@NonNull SeekBar seekBar) { } @Override - public void onStartTrackingTouch(SeekBar seekBar) { + public void onStartTrackingTouch(@NonNull SeekBar seekBar) { } @Override - public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + public void onProgressChanged(@NonNull SeekBar seekBar, int progress, boolean fromUser) { mImageSize = MediaSettingsImageSize.values()[progress]; mImageSizeView.setText(mImageSize.getLabel()); } @@ -865,7 +865,7 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis */ private final BroadcastReceiver mDownloadReceiver = new BroadcastReceiver() { @Override - public void onReceive(Context context, Intent intent) { + public void onReceive(@NonNull Context context, @NonNull Intent intent) { long thisId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1); if (thisId == mDownloadId) { DownloadManager.Query query = new DownloadManager.Query(); From 387099e560a76402e9b38a3c7aef544b3e670157 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 11 Aug 2023 16:19:38 +0300 Subject: [PATCH 24/59] Analysis: Add missing n-a to sdk override methods for notifications FYI: 'n-a' stands for 'nullability annotations'. --- .../ui/notifications/NotificationsDetailActivity.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsDetailActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsDetailActivity.java index f686f071bd47..019b3be8f28f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsDetailActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsDetailActivity.java @@ -107,7 +107,7 @@ public class NotificationsDetailActivity extends LocaleAwareActivity implements private Toolbar mToolbar; @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getApplication()).component().inject(this); AppLog.i(AppLog.T.NOTIFS, "Creating NotificationsDetailActivity"); @@ -282,7 +282,7 @@ public void showHideToolbar(boolean hide) { } @Override - public boolean onOptionsItemSelected(MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { if (item.getItemId() == android.R.id.home) { finish(); return true; @@ -292,7 +292,7 @@ public boolean onOptionsItemSelected(MenuItem item) { } @Override - protected void onSaveInstanceState(Bundle outState) { + protected void onSaveInstanceState(@NonNull Bundle outState) { if (getSupportActionBar() != null && getSupportActionBar().getTitle() != null) { outState.putString(ARG_TITLE, getSupportActionBar().getTitle().toString()); } @@ -606,6 +606,7 @@ private class NotificationDetailFragmentAdapter extends FragmentStatePagerAdapte mNoteList = (ArrayList) notes.clone(); } + @NonNull @Override public Fragment getItem(int position) { return getDetailFragmentForNote(mNoteList.get(position)); @@ -617,7 +618,7 @@ public int getCount() { } @Override - public void restoreState(Parcelable state, ClassLoader loader) { + public void restoreState(@Nullable Parcelable state, @Nullable ClassLoader loader) { // work around "Fragment no longer exists for key" Android bug // by catching the IllegalStateException // https://code.google.com/p/android/issues/detail?id=42601 @@ -629,6 +630,7 @@ public void restoreState(Parcelable state, ClassLoader loader) { } } + @Nullable @Override public Parcelable saveState() { AppLog.d(AppLog.T.NOTIFS, "notifications pager > adapter saveState"); From 4db5b4ec2e77c0c052476c209452eb1717cd70ae Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 11 Aug 2023 16:26:13 +0300 Subject: [PATCH 25/59] Analysis: Add missing n-a to sdk override methods for people management FYI: 'n-a' stands for 'nullability annotations'. --- .../android/ui/people/PeopleManagementActivity.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleManagementActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleManagementActivity.java index 4d2214c3a7ca..c5d1a4afa162 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleManagementActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleManagementActivity.java @@ -5,6 +5,8 @@ import android.view.MenuItem; import androidx.activity.OnBackPressedCallback; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.Fragment; @@ -96,7 +98,7 @@ public class PeopleManagementActivity extends LocaleAwareActivity private SiteModel mSite; @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDispatcher.register(this); @@ -189,7 +191,7 @@ public void handleOnBackPressed() { } @Override - public void onSaveInstanceState(Bundle outState) { + public void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); outState.putSerializable(WordPress.SITE, mSite); @@ -230,7 +232,7 @@ public void onStop() { } @Override - public boolean onOptionsItemSelected(final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull final MenuItem item) { if (item.getItemId() == android.R.id.home) { getOnBackPressedDispatcher().onBackPressed(); return true; @@ -514,7 +516,7 @@ private void confirmRemovePerson() { builder.setNegativeButton(R.string.cancel, null); builder.setPositiveButton(R.string.remove, new DialogInterface.OnClickListener() { @Override - public void onClick(DialogInterface dialog, int which) { + public void onClick(@Nullable DialogInterface dialog, int which) { removeSelectedPerson(); } }); From cd60734d036ffca3dc3db502f1edd6dbbc1cef7a Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 11 Aug 2023 16:27:52 +0300 Subject: [PATCH 26/59] Analysis: Add missing n-a to sdk override methods for photo picker FYI: 'n-a' stands for 'nullability annotations'. --- .../android/ui/photopicker/PhotoPickerActivity.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/photopicker/PhotoPickerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/photopicker/PhotoPickerActivity.java index c2d20a8a8446..f57454d6bf7f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/photopicker/PhotoPickerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/photopicker/PhotoPickerActivity.java @@ -146,7 +146,7 @@ private PhotoPickerFragment getPickerFragment() { } @Override - protected void onSaveInstanceState(Bundle outState) { + protected void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); outState.putSerializable(ARG_BROWSER_TYPE, mBrowserType); outState.putInt(MediaPickerConstants.LOCAL_POST_ID, mLocalPostId); @@ -159,13 +159,13 @@ protected void onSaveInstanceState(Bundle outState) { } @Override - protected void onRestoreInstanceState(Bundle savedInstanceState) { + protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); mMediaCapturePath = savedInstanceState.getString(KEY_MEDIA_CAPTURE_PATH); } @Override - public boolean onOptionsItemSelected(final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull final MenuItem item) { if (item.getItemId() == android.R.id.home) { setResult(RESULT_CANCELED); finish(); @@ -175,7 +175,7 @@ public boolean onOptionsItemSelected(final MenuItem item) { } @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode != Activity.RESULT_OK) { From 4b0d8a35a1ffba46be2ceb667bd8b2a35cc22162 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 11 Aug 2023 16:34:19 +0300 Subject: [PATCH 27/59] Analysis: Add missing n-a to sdk override methods for plugin browser FYI: 'n-a' stands for 'nullability annotations'. --- .../ui/plugins/PluginBrowserActivity.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginBrowserActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginBrowserActivity.java index a49a1ac15cbb..dfcb8dcfa8ec 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginBrowserActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginBrowserActivity.java @@ -76,7 +76,7 @@ public class PluginBrowserActivity extends LocaleAwareActivity private SearchView mSearchView; @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getApplication()).component().inject(this); setContentView(R.layout.plugin_browser_activity); @@ -216,7 +216,7 @@ protected void onDestroy() { } @Override - public boolean onCreateOptionsMenu(Menu menu) { + public boolean onCreateOptionsMenu(@NonNull Menu menu) { getMenuInflater().inflate(R.menu.search, menu); mSearchMenuItem = menu.findItem(R.id.menu_search); @@ -236,7 +236,7 @@ public boolean onCreateOptionsMenu(Menu menu) { } @Override - public boolean onOptionsItemSelected(final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull final MenuItem item) { if (item.getItemId() == android.R.id.home) { getOnBackPressedDispatcher().onBackPressed(); return true; @@ -287,7 +287,7 @@ private void reloadPluginAdapterAndVisibility(@NonNull PluginListType pluginType } @Override - public boolean onQueryTextSubmit(String query) { + public boolean onQueryTextSubmit(@NonNull String query) { if (mSearchView != null) { mSearchView.clearFocus(); } @@ -296,8 +296,8 @@ public boolean onQueryTextSubmit(String query) { } @Override - public boolean onQueryTextChange(String query) { - mViewModel.setSearchQuery(query != null ? query : ""); + public boolean onQueryTextChange(@NonNull String query) { + mViewModel.setSearchQuery(query); return true; } @@ -328,14 +328,14 @@ private void showProgress(boolean show) { } @Override - public boolean onMenuItemActionExpand(MenuItem menuItem) { + public boolean onMenuItemActionExpand(@NonNull MenuItem menuItem) { showListFragment(PluginListType.SEARCH); mSearchView.setOnQueryTextListener(this); return true; } @Override - public boolean onMenuItemActionCollapse(MenuItem menuItem) { + public boolean onMenuItemActionCollapse(@NonNull MenuItem menuItem) { mSearchView.setOnQueryTextListener(null); hideListFragment(); mViewModel.setSearchQuery(""); From 9a80cba7c7eab5cf2fa45a06f6f6767274e39e37 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 11 Aug 2023 16:36:27 +0300 Subject: [PATCH 28/59] Analysis: Add missing n-a to sdk override methods for plugin detail FYI: 'n-a' stands for 'nullability annotations'. --- .../android/ui/plugins/PluginDetailActivity.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginDetailActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginDetailActivity.java index ac895bf7a815..8533fcbb8cc9 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginDetailActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginDetailActivity.java @@ -189,7 +189,7 @@ public class PluginDetailActivity extends LocaleAwareActivity implements OnDomai @Inject ImageManager mImageManager; @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getApplication()).component().inject(this); mDispatcher.register(this); @@ -354,7 +354,7 @@ public static class DomainRegistrationPromptDialog extends DialogFragment { @NonNull @Override - public Dialog onCreateDialog(Bundle savedInstanceState) { + public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { AlertDialog.Builder builder = new MaterialAlertDialogBuilder(getActivity()); builder.setTitle(R.string.plugin_install_custom_domain_required_dialog_title); builder.setMessage(R.string.plugin_install_custom_domain_required_dialog_message); @@ -393,20 +393,20 @@ protected void onDestroy() { } @Override - public boolean onCreateOptionsMenu(Menu menu) { + public boolean onCreateOptionsMenu(@NonNull Menu menu) { getMenuInflater().inflate(R.menu.plugin_detail, menu); return super.onCreateOptionsMenu(menu); } @Override - public boolean onPrepareOptionsMenu(Menu menu) { + public boolean onPrepareOptionsMenu(@NonNull Menu menu) { boolean showTrash = canPluginBeDisabledOrRemoved(); menu.findItem(R.id.menu_trash).setVisible(showTrash); return super.onPrepareOptionsMenu(menu); } @Override - public boolean onOptionsItemSelected(final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull final MenuItem item) { if (item.getItemId() == android.R.id.home) { if (isPluginStateChangedSinceLastConfigurationDispatch()) { // It looks like we have some unsaved changes, we need to force a configuration dispatch since the From 2f3028f2af9a3508e5e18305a6ede1c73fab921a Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 11 Aug 2023 16:51:48 +0300 Subject: [PATCH 29/59] Analysis: Add missing n-a to sdk override methods for edit post FYI: 'n-a' stands for 'nullability annotations'. --- .../android/ui/posts/EditPostActivity.java | 115 +++++++++++------- 1 file changed, 74 insertions(+), 41 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java index 6492d6ef3e44..50bcaf70e8e6 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java @@ -557,8 +557,9 @@ private void createEditShareMessageActivityResultLauncher() { }); } - @Override @SuppressWarnings("checkstyle:MethodLength") - protected void onCreate(Bundle savedInstanceState) { + @Override + @SuppressWarnings("checkstyle:MethodLength") + protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getApplication()).component().inject(this); @@ -1103,7 +1104,8 @@ protected void onPause() { AnalyticsTracker.track(AnalyticsTracker.Stat.EDITOR_CLOSED); } - @Override protected void onStop() { + @Override + protected void onStop() { super.onStop(); if (mAztecImageLoader != null && isFinishing()) { mAztecImageLoader.clearTargets(); @@ -1147,7 +1149,7 @@ private void removePostOpenInEditorStickyEvent() { } @Override - protected void onSaveInstanceState(Bundle outState) { + protected void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); // Saves both post objects so we can restore them in onCreate() updateAndSavePostAsync(); @@ -1181,7 +1183,7 @@ protected void onSaveInstanceState(Bundle outState) { } @Override - protected void onRestoreInstanceState(Bundle savedInstanceState) { + protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); mHtmlModeMenuStateOn = savedInstanceState.getBoolean(STATE_KEY_HTML_MODE_ON); @@ -1196,7 +1198,7 @@ protected void onRestoreInstanceState(Bundle savedInstanceState) { } @Override - public void onConfigurationChanged(Configuration newConfig) { + public void onConfigurationChanged(@NonNull Configuration newConfig) { super.onConfigurationChanged(newConfig); mEditorPhotoPicker.onOrientationChanged(newConfig.orientation); @@ -1349,7 +1351,7 @@ public void onPhotoPickerIconClicked(@NonNull PhotoPickerIcon icon, boolean allo } @Override - public boolean onCreateOptionsMenu(Menu menu) { + public boolean onCreateOptionsMenu(@NonNull Menu menu) { super.onCreateOptionsMenu(menu); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.edit_post, menu); @@ -1357,7 +1359,7 @@ public boolean onCreateOptionsMenu(Menu menu) { } @Override - public boolean onPrepareOptionsMenu(Menu menu) { + public boolean onPrepareOptionsMenu(@NonNull Menu menu) { boolean showMenuItems = true; if (mViewPager != null && mViewPager.getCurrentItem() > PAGE_CONTENT) { showMenuItems = false; @@ -1511,7 +1513,8 @@ private boolean handleBackPressed() { mEditorPhotoPicker.hidePhotoPicker(); } else { performWhenNoStoriesBeingSaved(new DoWhenNoStoriesBeingSavedCallback() { - @Override public void doWhenNoStoriesBeingSaved() { + @Override + public void doWhenNoStoriesBeingSaved() { savePostAndOptionallyFinish(true, false); } }); @@ -1575,7 +1578,7 @@ public void notifyEmptyPost() { // Menu actions @Override - public boolean onOptionsItemSelected(final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull final MenuItem item) { int itemId = item.getItemId(); if (itemId == android.R.id.home) { @@ -2038,11 +2041,13 @@ public void onImageSettingsRequested(EditorImageMetaData editorImageMetaData) { } - @Override public void onImagePreviewRequested(String mediaUrl) { + @Override + public void onImagePreviewRequested(String mediaUrl) { MediaPreviewActivity.showPreview(this, mSite, mediaUrl); } - @Override public void onMediaEditorRequested(String mediaUrl) { + @Override + public void onMediaEditorRequested(String mediaUrl) { String imageUrl = UrlUtils.removeQuery(StringUtils.notNullStr(mediaUrl)); // We're using a separate cache in WPAndroid and RN's Gutenberg editor so we need to reload the image @@ -2171,7 +2176,8 @@ private void setupPrepublishingBottomSheetRunnable() { private void checkNoStorySaveOperationInProgressAndShowPrepublishingNudgeBottomSheet() { performWhenNoStoriesBeingSaved(new DoWhenNoStoriesBeingSavedCallback() { - @Override public void doWhenNoStoriesBeingSaved() { + @Override + public void doWhenNoStoriesBeingSaved() { showPrepublishingNudgeBottomSheet(); } }); @@ -2184,7 +2190,8 @@ private void showPrepublishingNudgeBottomSheet() { mShowPrepublishingBottomSheetHandler.postDelayed(mShowPrepublishingBottomSheetRunnable, delayMs); } - @Override public void onSubmitButtonClicked(boolean publishPost) { + @Override + public void onSubmitButtonClicked(boolean publishPost) { uploadPost(publishPost); if (publishPost) { AppRatingDialog.INSTANCE @@ -2353,6 +2360,7 @@ public class SectionsPagerAdapter extends FragmentPagerAdapter { super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT); } + @NonNull @Override public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. @@ -2407,8 +2415,9 @@ public Fragment getItem(int position) { } } + @NonNull @Override - public @NonNull Object instantiateItem(@NonNull ViewGroup container, int position) { + public Object instantiateItem(@NonNull ViewGroup container, int position) { Fragment fragment = (Fragment) super.instantiateItem(container, position); switch (position) { case PAGE_CONTENT: @@ -2777,7 +2786,7 @@ private void setPageContent() { @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); // In case of Remote Preview we need to change state even if (resultCode != Activity.RESULT_OK) @@ -3169,13 +3178,15 @@ public void onAddLibraryMediaClicked(boolean allowMultipleSelection) { } } - @Override public void onAddLibraryFileClicked(boolean allowMultipleSelection) { + @Override + public void onAddLibraryFileClicked(boolean allowMultipleSelection) { mEditorPhotoPicker.setAllowMultipleSelection(allowMultipleSelection); mMediaPickerLauncher .viewWPMediaLibraryPickerForResult(this, mSite, MediaBrowserType.GUTENBERG_SINGLE_FILE_PICKER); } - @Override public void onAddLibraryAudioFileClicked(boolean allowMultipleSelection) { + @Override + public void onAddLibraryAudioFileClicked(boolean allowMultipleSelection) { mMediaPickerLauncher .viewWPMediaLibraryPickerForResult(this, mSite, MediaBrowserType.GUTENBERG_SINGLE_AUDIO_FILE_PICKER); } @@ -3233,11 +3244,13 @@ public void onAddFileClicked(boolean allowMultipleSelection) { mMediaPickerLauncher.showFilePicker(this, allowMultipleSelection, getSite()); } - @Override public void onAddAudioFileClicked(boolean allowMultipleSelection) { + @Override + public void onAddAudioFileClicked(boolean allowMultipleSelection) { mMediaPickerLauncher.showAudioFilePicker(this, allowMultipleSelection, getSite()); } - @Override public void onPerformFetch( + @Override + public void onPerformFetch( String path, boolean enableCaching, Consumer onResult, @@ -3248,7 +3261,8 @@ public void onAddFileClicked(boolean allowMultipleSelection) { } } - @Override public void onPerformPost( + @Override + public void onPerformPost( String path, Map body, Consumer onResult, @@ -3513,11 +3527,13 @@ private void logTemplateSelection() { mPostEditorAnalyticsSession.applyTemplate(template); } - @Override public void showUserSuggestions(Consumer onResult) { + @Override + public void showUserSuggestions(Consumer onResult) { showSuggestions(SuggestionType.Users, onResult); } - @Override public void showXpostSuggestions(Consumer onResult) { + @Override + public void showXpostSuggestions(Consumer onResult) { showSuggestions(SuggestionType.XPosts, onResult); } @@ -3526,11 +3542,13 @@ private void showSuggestions(SuggestionType type, Consumer onResult) { ActivityLauncher.viewSuggestionsForResult(this, mSite, type); } - @Override public void onGutenbergEditorSetFocalPointPickerTooltipShown(boolean tooltipShown) { + @Override + public void onGutenbergEditorSetFocalPointPickerTooltipShown(boolean tooltipShown) { AppPrefs.setGutenbergFocalPointPickerTooltipShown(tooltipShown); } - @Override public boolean onGutenbergEditorRequestFocalPointPickerTooltipShown() { + @Override + public boolean onGutenbergEditorRequestFocalPointPickerTooltipShown() { return AppPrefs.getGutenbergFocalPointPickerTooltipShown(); } @@ -3561,7 +3579,8 @@ public void onTrackableEvent(TrackableEvent event, Map propertie mEditorTracker.trackEditorEvent(event, mEditorFragment.getEditorName(), properties); } - @Override public void onStoryComposerLoadRequested(ArrayList mediaFiles, String blockId) { + @Override + public void onStoryComposerLoadRequested(ArrayList mediaFiles, String blockId) { // we need to save the latest before editing updateAndSavePostAsync(updatePostResult -> { boolean noSlidesLoaded = mStoriesEventListener.onRequestMediaFilesEditorLoad( @@ -3579,19 +3598,23 @@ public void onTrackableEvent(TrackableEvent event, Map propertie }); } - @Override public void onRetryUploadForMediaCollection(ArrayList mediaFiles) { + @Override + public void onRetryUploadForMediaCollection(ArrayList mediaFiles) { mStoriesEventListener.onRetryUploadForMediaCollection(this, mediaFiles, mEditorMediaUploadListener); } - @Override public void onCancelUploadForMediaCollection(ArrayList mediaFiles) { + @Override + public void onCancelUploadForMediaCollection(ArrayList mediaFiles) { mStoriesEventListener.onCancelUploadForMediaCollection(mediaFiles); } - @Override public void onCancelSaveForMediaCollection(ArrayList mediaFiles) { + @Override + public void onCancelSaveForMediaCollection(ArrayList mediaFiles) { mStoriesEventListener.onCancelSaveForMediaCollection(mediaFiles); } - @Override public boolean showPreview() { + @Override + public boolean showPreview() { PreviewLogicOperationResult opResult = mRemotePreviewLogicHelper.runPostPreviewLogic( this, mSite, @@ -3608,34 +3631,41 @@ public void onTrackableEvent(TrackableEvent event, Map propertie return true; } - @Override public Map onRequestBlockTypeImpressions() { + @Override + public Map onRequestBlockTypeImpressions() { return AppPrefs.getGutenbergBlockTypeImpressions(); } - @Override public void onSetBlockTypeImpressions(Map impressions) { + @Override + public void onSetBlockTypeImpressions(Map impressions) { AppPrefs.setGutenbergBlockTypeImpressions(impressions); } - @Override public void onContactCustomerSupport() { + @Override + public void onContactCustomerSupport() { EditPostCustomerSupportHelper.INSTANCE.onContactCustomerSupport(mZendeskHelper, this, getSite()); } - @Override public void onGotoCustomerSupportOptions() { + @Override + public void onGotoCustomerSupportOptions() { EditPostCustomerSupportHelper.INSTANCE.onGotoCustomerSupportOptions(this, getSite()); } - @Override public void onSendEventToHost(String eventName, Map properties) { + @Override + public void onSendEventToHost(String eventName, Map properties) { AnalyticsUtils.trackBlockEditorEvent(eventName, mSite, properties); } - @Override public void onToggleUndo(boolean isDisabled) { + @Override + public void onToggleUndo(boolean isDisabled) { if (mMenuHasUndo == !isDisabled) return; mMenuHasUndo = !isDisabled; new Handler(Looper.getMainLooper()).post(this::invalidateOptionsMenu); } - @Override public void onToggleRedo(boolean isDisabled) { + @Override + public void onToggleRedo(boolean isDisabled) { if (mMenuHasRedo == !isDisabled) return; mMenuHasRedo = !isDisabled; @@ -3863,7 +3893,7 @@ public AztecImageLoader getAztecImageLoader() { } @Override - public boolean onMenuOpened(int featureId, Menu menu) { + public boolean onMenuOpened(int featureId, @NonNull Menu menu) { // This is a workaround for bag discovered on Chromebooks, where Enter key will not work in the toolbar menu // Editor fragments are messing with window focus, which causes keyboard events to get ignored @@ -3886,7 +3916,8 @@ public void appendMediaFiles(@NonNull Map mediaFile mEditorFragment.appendMediaFiles((Map) mediaFiles); } - @NonNull @Override + @NonNull + @Override public PostImmutableModel getImmutablePost() { return Objects.requireNonNull(mEditPostRepository.getPost()); } @@ -3896,7 +3927,8 @@ public void syncPostObjectWithUiAndSaveIt(@Nullable OnPostUpdatedFromUIListener updateAndSavePostAsync(listener); } - @Override public void advertiseImageOptimization(@NonNull Function0 listener) { + @Override + public void advertiseImageOptimization(@NonNull Function0 listener) { WPMediaUtils.advertiseImageOptimization(this, listener::invoke); } @@ -3905,7 +3937,8 @@ public void onMediaModelsCreatedFromOptimizedUris(@NonNull Map Date: Fri, 11 Aug 2023 16:59:49 +0300 Subject: [PATCH 30/59] Analysis: Add missing n-a to sdk override methods for post settings tag FYI: 'n-a' stands for 'nullability annotations'. --- .../android/ui/posts/PostSettingsTagsActivity.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostSettingsTagsActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostSettingsTagsActivity.java index 6c6d0674db5d..d20e83dfe104 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostSettingsTagsActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostSettingsTagsActivity.java @@ -6,6 +6,7 @@ import androidx.activity.OnBackPressedCallback; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; @@ -24,7 +25,7 @@ public class PostSettingsTagsActivity extends LocaleAwareActivity implements Tag private String mTags; @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); OnBackPressedCallback callback = new OnBackPressedCallback(true) { @@ -72,13 +73,13 @@ private void showPostSettingsTagsFragment() { } @Override - protected void onSaveInstanceState(Bundle outState) { + protected void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); outState.putSerializable(WordPress.SITE, mSite); } @Override - public boolean onOptionsItemSelected(final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull final MenuItem item) { int itemId = item.getItemId(); if (itemId == android.R.id.home) { saveAndFinish(); @@ -106,7 +107,8 @@ private void closeKeyboard() { } } - @Override public void onTagsSelected(@NonNull String selectedTags) { + @Override + public void onTagsSelected(@NonNull String selectedTags) { mTags = selectedTags; } } From 319c59afbebb9ecdb5168336cbba6e7145f05fca Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 11 Aug 2023 17:01:13 +0300 Subject: [PATCH 31/59] Analysis: Add missing n-a to sdk override methods for select categories FYI: 'n-a' stands for 'nullability annotations'. --- .../android/ui/posts/SelectCategoriesActivity.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/SelectCategoriesActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/SelectCategoriesActivity.java index 3042107eacc8..56ca22954e1a 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/SelectCategoriesActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/SelectCategoriesActivity.java @@ -11,6 +11,8 @@ import android.widget.TextView; import androidx.activity.OnBackPressedCallback; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; @@ -68,7 +70,7 @@ public class SelectCategoriesActivity extends LocaleAwareActivity { @Inject Dispatcher mDispatcher; @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getApplication()).component().inject(this); @@ -199,13 +201,13 @@ private void showAddCategoryFragment() { } @Override - protected void onSaveInstanceState(Bundle outState) { + protected void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); outState.putSerializable(WordPress.SITE, mSite); } @Override - public boolean onCreateOptionsMenu(Menu menu) { + public boolean onCreateOptionsMenu(@NonNull Menu menu) { super.onCreateOptionsMenu(menu); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.categories, menu); @@ -227,7 +229,7 @@ public void categoryAdded(TermModel newCategory) { } @Override - public boolean onOptionsItemSelected(final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull final MenuItem item) { int itemId = item.getItemId(); if (itemId == R.id.menu_new_category) { if (NetworkUtils.checkConnection(this)) { From 0fde6d4d877e9504e39bfdf207e3e8c60005c2f2 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 11 Aug 2023 17:01:55 +0300 Subject: [PATCH 32/59] Analysis: Add missing n-a to sdk override methods for account settings FYI: 'n-a' stands for 'nullability annotations'. --- .../wordpress/android/ui/prefs/AccountSettingsActivity.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AccountSettingsActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AccountSettingsActivity.java index 89f4e78fbbc5..c500ad105cf8 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AccountSettingsActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AccountSettingsActivity.java @@ -3,6 +3,8 @@ import android.os.Bundle; import android.view.MenuItem; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.widget.Toolbar; @@ -14,7 +16,7 @@ @AndroidEntryPoint public class AccountSettingsActivity extends LocaleAwareActivity { @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.account_settings_activity); @@ -30,7 +32,7 @@ public void onCreate(Bundle savedInstanceState) { } @Override - public boolean onOptionsItemSelected(final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull final MenuItem item) { if (item.getItemId() == android.R.id.home) { getOnBackPressedDispatcher().onBackPressed(); return true; From 1389ddd28b9c9a34bf9f4c671449e1c281c65a6c Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 11 Aug 2023 17:02:51 +0300 Subject: [PATCH 33/59] Analysis: Add missing n-a to sdk override methods for blog preferences FYI: 'n-a' stands for 'nullability annotations'. --- .../android/ui/prefs/BlogPreferencesActivity.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/BlogPreferencesActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/BlogPreferencesActivity.java index b9c4ac81caa6..3b372c4f7603 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/BlogPreferencesActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/BlogPreferencesActivity.java @@ -4,6 +4,8 @@ import android.os.Bundle; import android.view.MenuItem; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.widget.Toolbar; @@ -42,7 +44,7 @@ public class BlogPreferencesActivity extends LocaleAwareActivity { @Inject Dispatcher mDispatcher; @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getApplication()).component().inject(this); setContentView(R.layout.site_settings_activity); @@ -99,13 +101,13 @@ protected void onStop() { } @Override - public void onSaveInstanceState(Bundle outState) { + public void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); outState.putSerializable(WordPress.SITE, mSite); } @Override - public boolean onOptionsItemSelected(MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { int itemID = item.getItemId(); if (itemID == android.R.id.home) { finish(); From 05fcb5375d7dac5e3a3713cd98c16d1aec6d8bf0 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 11 Aug 2023 17:04:40 +0300 Subject: [PATCH 34/59] Analysis: Add missing n-a to sdk override methods for my profile FYI: 'n-a' stands for 'nullability annotations'. --- .../org/wordpress/android/ui/prefs/MyProfileActivity.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/MyProfileActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/MyProfileActivity.java index 03e50ff2e6b1..c2f700e4126e 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/MyProfileActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/MyProfileActivity.java @@ -3,6 +3,8 @@ import android.os.Bundle; import android.view.MenuItem; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.widget.Toolbar; @@ -19,7 +21,7 @@ public class MyProfileActivity extends LocaleAwareActivity { @Inject AccountStore mAccountStore; @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getApplication()).component().inject(this); @@ -37,7 +39,7 @@ public void onCreate(Bundle savedInstanceState) { } @Override - public boolean onOptionsItemSelected(final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull final MenuItem item) { if (item.getItemId() == android.R.id.home) { getOnBackPressedDispatcher().onBackPressed(); return true; From ac5ac3ef072a758e70d145fe69aa429757f0a7df Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 11 Aug 2023 17:07:00 +0300 Subject: [PATCH 35/59] Analysis: Add missing n-a to sdk override methods for site settings list FYI: 'n-a' stands for 'nullability annotations'. --- .../ui/prefs/SiteSettingsTagListActivity.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTagListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTagListActivity.java index 863d92fd65c1..2033843326f6 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTagListActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTagListActivity.java @@ -93,7 +93,7 @@ public static void showTagList(@NonNull Context context, @NonNull SiteModel site } @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getApplication()).component().inject(this); @@ -214,7 +214,7 @@ protected void onSaveInstanceState(@NonNull Bundle outState) { } @Override - public boolean onCreateOptionsMenu(Menu menu) { + public boolean onCreateOptionsMenu(@NonNull Menu menu) { getMenuInflater().inflate(R.menu.tag_list, menu); mSearchMenuItem = menu.findItem(R.id.menu_search); @@ -234,7 +234,7 @@ public boolean onCreateOptionsMenu(Menu menu) { } @Override - public boolean onOptionsItemSelected(final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull final MenuItem item) { if (item.getItemId() == android.R.id.home) { getOnBackPressedDispatcher().onBackPressed(); return true; @@ -356,19 +356,19 @@ private void showActionableEmptyViewForSearch(boolean isSearch) { } @Override - public boolean onQueryTextSubmit(String query) { + public boolean onQueryTextSubmit(@NonNull String query) { mAdapter.filter(query); return false; } @Override - public boolean onQueryTextChange(String query) { + public boolean onQueryTextChange(@NonNull String query) { mAdapter.filter(query); return false; } @Override - public boolean onMenuItemActionExpand(MenuItem item) { + public boolean onMenuItemActionExpand(@NonNull MenuItem item) { mIsSearching = true; showActionableEmptyViewForSearch(true); hideFabIfShowing(); @@ -376,7 +376,7 @@ public boolean onMenuItemActionExpand(MenuItem item) { } @Override - public boolean onMenuItemActionCollapse(MenuItem item) { + public boolean onMenuItemActionCollapse(@NonNull MenuItem item) { mIsSearching = false; showActionableEmptyViewForSearch(false); showFabWithConditions(); From adf47443356494e962e5d47480a0785cc0577162 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 11 Aug 2023 17:08:04 +0300 Subject: [PATCH 36/59] Analysis: Add missing n-a to sdk override methods for publicize list FYI: 'n-a' stands for 'nullability annotations'. --- .../android/ui/publicize/PublicizeListActivity.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeListActivity.java index df73638d7d99..9e181713ec01 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeListActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeListActivity.java @@ -6,6 +6,7 @@ import androidx.activity.OnBackPressedCallback; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.widget.Toolbar; @@ -62,7 +63,7 @@ public class PublicizeListActivity extends LocaleAwareActivity @Inject JetpackBrandingUtils mJetpackBrandingUtils; @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.publicize_list_activity); @@ -216,7 +217,7 @@ private void closeWebViewFragment() { } @Override - public boolean onOptionsItemSelected(final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull final MenuItem item) { int itemId = item.getItemId(); if (itemId == android.R.id.home) { getOnBackPressedDispatcher().onBackPressed(); From d099dda62da7a78d07533c94402a93db06e0cc14 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Fri, 11 Aug 2023 17:17:51 +0300 Subject: [PATCH 37/59] Analysis: Add missing n-a to sdk override methods for reader comment lst FYI: 'n-a' stands for 'nullability annotations'. --- .../ui/reader/ReaderCommentListActivity.java | 96 +++++++++---------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderCommentListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderCommentListActivity.java index 82e689be2cd9..8132fc467461 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderCommentListActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderCommentListActivity.java @@ -154,7 +154,7 @@ public class ReaderCommentListActivity extends LocaleAwareActivity implements On private ConversationNotificationsViewModel mConversationViewModel; @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.reader_activity_comment_list); @@ -207,15 +207,15 @@ public void handleOnBackPressed() { mEditComment.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())); } }); @@ -317,7 +317,8 @@ private void initObservers(Bundle savedInstanceState) { if (content != null && layoutManager != null) { if (content.isSmooth()) { RecyclerView.SmoothScroller smoothScrollerToTop = new LinearSmoothScroller(this) { - @Override protected int getVerticalSnapPreference() { + @Override + protected int getVerticalSnapPreference() { return LinearSmoothScroller.SNAP_TO_START; } }; @@ -416,7 +417,7 @@ public void onConfirm(@Nullable Bundle result) { private final View.OnClickListener mSignInClickListener = new View.OnClickListener() { @Override - public void onClick(View v) { + public void onClick(@NonNull View v) { if (isFinishing()) { return; } @@ -468,54 +469,52 @@ public void onEventMainThread(SuggestionEvents.SuggestionNameListUpdated event) } @Override - public boolean onCreateOptionsMenu(Menu menu) { + public boolean onCreateOptionsMenu(@NonNull Menu menu) { super.onCreateOptionsMenu(menu); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.threaded_comments_menu, menu); mConversationViewModel.getUpdateFollowUiState().observe(this, uiState -> { - if (menu != null) { - MenuItem bellItem = menu.findItem(R.id.manage_notifications_item); - MenuItem followItem = menu.findItem(R.id.follow_item); - - if (bellItem != null && followItem != null) { - ShimmerFrameLayout shimmerView = - followItem.getActionView().findViewById(R.id.shimmer_view_container); - TextView followText = followItem.getActionView().findViewById(R.id.follow_button); - - followItem.getActionView().setOnClickListener( - uiState.getOnFollowTapped() != null - ? v -> uiState.getOnFollowTapped().invoke() - : null - ); + MenuItem bellItem = menu.findItem(R.id.manage_notifications_item); + MenuItem followItem = menu.findItem(R.id.follow_item); + + if (bellItem != null && followItem != null) { + ShimmerFrameLayout shimmerView = + followItem.getActionView().findViewById(R.id.shimmer_view_container); + TextView followText = followItem.getActionView().findViewById(R.id.follow_button); + + followItem.getActionView().setOnClickListener( + uiState.getOnFollowTapped() != null + ? v -> uiState.getOnFollowTapped().invoke() + : null + ); - bellItem.setOnMenuItemClickListener(item -> { - uiState.getOnManageNotificationsTapped().invoke(); - return true; - }); - - followItem.getActionView().setEnabled(uiState.getFlags().isMenuEnabled()); - followText.setEnabled(uiState.getFlags().isMenuEnabled()); - bellItem.setEnabled(uiState.getFlags().isMenuEnabled()); - - if (uiState.getFlags().getShowMenuShimmer()) { - if (!shimmerView.isShimmerVisible()) { - shimmerView.showShimmer(true); - } else if (!shimmerView.isShimmerStarted()) { - shimmerView.startShimmer(); - } - } else { - shimmerView.hideShimmer(); - } + bellItem.setOnMenuItemClickListener(item -> { + uiState.getOnManageNotificationsTapped().invoke(); + return true; + }); - followItem.setVisible(uiState.getFlags().isFollowMenuVisible()); - bellItem.setVisible(uiState.getFlags().isBellMenuVisible()); + followItem.getActionView().setEnabled(uiState.getFlags().isMenuEnabled()); + followText.setEnabled(uiState.getFlags().isMenuEnabled()); + bellItem.setEnabled(uiState.getFlags().isMenuEnabled()); - setResult(RESULT_OK, new Intent().putExtra( - FOLLOW_CONVERSATION_UI_STATE_FLAGS_KEY, - uiState.getFlags() - )); + if (uiState.getFlags().getShowMenuShimmer()) { + if (!shimmerView.isShimmerVisible()) { + shimmerView.showShimmer(true); + } else if (!shimmerView.isShimmerStarted()) { + shimmerView.startShimmer(); + } + } else { + shimmerView.hideShimmer(); } + + followItem.setVisible(uiState.getFlags().isFollowMenuVisible()); + bellItem.setVisible(uiState.getFlags().isBellMenuVisible()); + + setResult(RESULT_OK, new Intent().putExtra( + FOLLOW_CONVERSATION_UI_STATE_FLAGS_KEY, + uiState.getFlags() + )); } } ); @@ -523,7 +522,7 @@ public boolean onCreateOptionsMenu(Menu menu) { } @Override - public boolean onOptionsItemSelected(MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case android.R.id.home: finish(); @@ -581,7 +580,8 @@ private void moderateComment(ReaderComment comment, CommentStatus newStatus, int }); snackbar.addCallback(new BaseCallback() { - @Override public void onDismissed(Snackbar transientBottomBar, int event) { + @Override + public void onDismissed(@Nullable Snackbar transientBottomBar, int event) { super.onDismissed(transientBottomBar, event); if (event == DISMISS_EVENT_ACTION) { @@ -1062,7 +1062,7 @@ private void setRefreshing(boolean refreshing) { } @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); // if user is returning from login, make sure to update the post and its comments From 526296172ec4d40daabd469af3fa7aa4cd62de81 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Wed, 16 Aug 2023 17:14:27 +0300 Subject: [PATCH 38/59] Analysis: Add missing n-a to sdk override methods for reader photo view FYI: 'n-a' stands for 'nullability annotations'. --- .../ui/reader/ReaderPhotoViewerActivity.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPhotoViewerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPhotoViewerActivity.java index 9e8dc104c46c..ce715f4f6ff7 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPhotoViewerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPhotoViewerActivity.java @@ -10,6 +10,7 @@ import android.widget.TextView; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.widget.Toolbar; import androidx.fragment.app.Fragment; @@ -47,7 +48,7 @@ public class ReaderPhotoViewerActivity extends LocaleAwareActivity private final Handler mFadeHandler = new Handler(); @Override - protected void onCreate(Bundle savedInstanceState) { + protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.reader_activity_photo_viewer); @@ -117,16 +118,16 @@ private void showToolbar() { if (mToolbar.getVisibility() != View.VISIBLE) { AniUtils.startAnimation(mToolbar, R.anim.toolbar_fade_in_and_down, new Animation.AnimationListener() { @Override - public void onAnimationStart(Animation animation) { + public void onAnimationStart(@NonNull Animation animation) { mToolbar.setVisibility(View.VISIBLE); } @Override - public void onAnimationEnd(Animation animation) { + public void onAnimationEnd(@NonNull Animation animation) { } @Override - public void onAnimationRepeat(Animation animation) { + public void onAnimationRepeat(@NonNull Animation animation) { } }); } @@ -139,16 +140,16 @@ public void run() { if (!isFinishing() && mToolbar.getVisibility() == View.VISIBLE) { AniUtils.startAnimation(mToolbar, R.anim.toolbar_fade_out_and_up, 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) { mToolbar.setVisibility(View.GONE); } @Override - public void onAnimationRepeat(Animation animation) { + public void onAnimationRepeat(@NonNull Animation animation) { } }); } @@ -156,7 +157,7 @@ public void onAnimationRepeat(Animation animation) { }; @Override - public boolean onOptionsItemSelected(MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { if (item.getItemId() == android.R.id.home) { getOnBackPressedDispatcher().onBackPressed(); return true; @@ -164,7 +165,8 @@ public boolean onOptionsItemSelected(MenuItem item) { return super.onOptionsItemSelected(item); } - @Override public void finish() { + @Override + public void finish() { super.finish(); overridePendingTransition(R.anim.fade_in, R.anim.fade_out); } @@ -268,7 +270,7 @@ void setImageList(ReaderImageList imageList, String initialImageUrl) { } @Override - public void restoreState(Parcelable state, ClassLoader loader) { + public void restoreState(@Nullable Parcelable state, @Nullable ClassLoader loader) { // work around "Fragement no longer exists for key" Android bug // by catching the IllegalStateException // https://code.google.com/p/android/issues/detail?id=42601 @@ -279,6 +281,7 @@ public void restoreState(Parcelable state, ClassLoader loader) { } } + @NonNull @Override public Fragment getItem(int position) { return ReaderPhotoViewerFragment.newInstance( From 3f017664a2a9b716336ba8e889c8a75a24617cd5 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Wed, 16 Aug 2023 17:16:09 +0300 Subject: [PATCH 39/59] Analysis: Add missing n-a to sdk override methods for reader post list FYI: 'n-a' stands for 'nullability annotations'. --- .../android/ui/reader/ReaderPostListActivity.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java index 8f6df01769f0..c5720d0495d4 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java @@ -10,6 +10,7 @@ import androidx.activity.OnBackPressedCallback; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.widget.Toolbar; import androidx.coordinatorlayout.widget.CoordinatorLayout; @@ -66,7 +67,7 @@ public class ReaderPostListActivity extends LocaleAwareActivity { @Inject SelectedSiteRepository mSelectedSiteRepository; @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.reader_activity_post_list); @@ -106,7 +107,7 @@ public void handleOnBackPressed() { } toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override - public void onClick(View view) { + public void onClick(@NonNull View view) { finish(); } }); @@ -204,7 +205,7 @@ public void onSaveInstanceState(@NonNull Bundle outState) { } @Override - public boolean onCreateOptionsMenu(Menu menu) { + public boolean onCreateOptionsMenu(@NonNull Menu menu) { if (getPostListType() == ReaderPostListType.BLOG_PREVIEW) { getMenuInflater().inflate(R.menu.share, menu); } @@ -213,7 +214,7 @@ public boolean onCreateOptionsMenu(Menu menu) { } @Override - public boolean onOptionsItemSelected(MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case android.R.id.home: getOnBackPressedDispatcher().onBackPressed(); @@ -316,7 +317,7 @@ private ReaderPostListFragment getListFragment() { } @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { @@ -348,7 +349,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { mUploadActionUseCase.getUploadAction(post), new View.OnClickListener() { @Override - public void onClick(View v) { + public void onClick(@NonNull View v) { UploadUtils.publishPost( ReaderPostListActivity.this, post, From 8a4126ef8663db5fb066654bca7ca674743e2a22 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Wed, 16 Aug 2023 17:16:49 +0300 Subject: [PATCH 40/59] Analysis: Suppress non constant res id lint warning for reader post list Warning Message: "Resource IDs will be non-final by default in Android Gradle Plugin version 8.0, avoid using them in const fields" Explanation: "Avoid the usage of resource IDs where constant expressions are required. A future version of the Android Gradle Plugin will generate R classes with non-constant IDs in order to improve the performance of incremental compilation." ------------------------------------------------------------------------ This Lint warning is suppressed, that is, instead of it being resolved, since a resolution would require a proper investigation. As such, it might be best to ignore this as out of scope, for now, and so as to not introduce any breaking changes with this upgrade overall. Related Commit: f8bc363cf39c000216b53bc8e910b00f5b6e1a89 --- .../org/wordpress/android/ui/reader/ReaderPostListActivity.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java index c5720d0495d4..0ff8a3cdb784 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java @@ -1,5 +1,6 @@ package org.wordpress.android.ui.reader; +import android.annotation.SuppressLint; import android.app.Activity; import android.content.ActivityNotFoundException; import android.content.Intent; @@ -214,6 +215,7 @@ public boolean onCreateOptionsMenu(@NonNull Menu menu) { } @Override + @SuppressLint("NonConstantResourceId") public boolean onOptionsItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case android.R.id.home: From 710aed51f4c0850764c4dc3fc3351123dcbf0a8d Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Wed, 16 Aug 2023 17:20:26 +0300 Subject: [PATCH 41/59] Analysis: Add missing n-a to sdk override methods for reader post pager FYI: 'n-a' stands for 'nullability annotations'. --- .../ui/reader/ReaderPostPagerActivity.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java index af0330ca09ac..eb7d6759b6af 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java @@ -15,6 +15,7 @@ import androidx.activity.OnBackPressedCallback; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentStatePagerAdapter; @@ -176,7 +177,7 @@ public enum DirectOperation { @Inject JetpackFeatureRemovalPhaseHelper mJetpackFeatureRemovalPhaseHelper; @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getApplication()).component().inject(this); mJetpackFullScreenViewModel = new ViewModelProvider(this).get(JetpackFeatureFullScreenOverlayViewModel.class); @@ -659,7 +660,7 @@ protected void onPause() { } @Override - public boolean onOptionsItemSelected(final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull final MenuItem item) { if (item.getItemId() == android.R.id.home) { finish(); return true; @@ -973,8 +974,8 @@ private class PostPagerAdapter extends FragmentStatePagerAdapter { } @Override - public void restoreState(Parcelable state, ClassLoader loader) { - // work around "Fragement no longer exists for key" Android bug + public void restoreState(@Nullable Parcelable state, @Nullable ClassLoader loader) { + // work around "Fragment no longer exists for key" Android bug // by catching the IllegalStateException // https://code.google.com/p/android/issues/detail?id=42601 try { @@ -985,6 +986,7 @@ public void restoreState(Parcelable state, ClassLoader loader) { } } + @Nullable @Override public Parcelable saveState() { AppLog.d(AppLog.T.READER, "reader pager > adapter saveState"); @@ -1007,6 +1009,7 @@ public int getCount() { return mIdList.size(); } + @NonNull @Override public Fragment getItem(int position) { if ((position == getCount() - 1) && canRequestMostPosts()) { @@ -1025,8 +1028,9 @@ public Fragment getItem(int position) { mPostSlugsResolutionUnderway); } + @NonNull @Override - public @NonNull Object instantiateItem(ViewGroup container, int position) { + public Object instantiateItem(@NonNull ViewGroup container, int position) { Object item = super.instantiateItem(container, position); if (item instanceof Fragment) { mFragmentMap.put(position, (Fragment) item); @@ -1035,7 +1039,7 @@ public Fragment getItem(int position) { } @Override - public void destroyItem(ViewGroup container, int position, Object object) { + public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) { mFragmentMap.remove(position); super.destroyItem(container, position, object); } @@ -1066,7 +1070,7 @@ ReaderBlogIdPostId getBlogIdPostIdAtPosition(int position) { } @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { From f40213ecccbd0eba9957f3bb6169080b9feb639e Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Wed, 16 Aug 2023 17:25:29 +0300 Subject: [PATCH 42/59] Analysis: Add missing n-a to sdk override methods for reader subs FYI: 'n-a' stands for 'nullability annotations'. --- .../wordpress/android/ui/reader/ReaderSubsActivity.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderSubsActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderSubsActivity.java index b3fa4d9de841..4d0e2be1cf79 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderSubsActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderSubsActivity.java @@ -91,7 +91,7 @@ public class ReaderSubsActivity extends LocaleAwareActivity @Inject ReaderTracker mReaderTracker; @Override - protected void onCreate(Bundle savedInstanceState) { + protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((WordPress) getApplication()).component().inject(this); @@ -533,6 +533,7 @@ private class SubsPageAdapter extends FragmentPagerAdapter { mFragments = fragments; } + @Nullable @Override public CharSequence getPageTitle(int position) { switch (position) { @@ -545,6 +546,7 @@ public CharSequence getPageTitle(int position) { } } + @NonNull @Override public Fragment getItem(int position) { return mFragments.get(position); @@ -555,8 +557,9 @@ public int getCount() { return mFragments.size(); } + @NonNull @Override - public Object instantiateItem(ViewGroup container, int position) { + public Object instantiateItem(@NonNull ViewGroup container, int position) { Object ret = super.instantiateItem(container, position); mFragments.set(position, (Fragment) ret); return ret; From 54191a42c6922d2a1d15056f049d2ae2e5e2237c Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Wed, 16 Aug 2023 17:26:20 +0300 Subject: [PATCH 43/59] Analysis: Add missing n-a to sdk override methods for reader user list FYI: 'n-a' stands for 'nullability annotations'. --- .../wordpress/android/ui/reader/ReaderUserListActivity.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderUserListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderUserListActivity.java index eaf13a0a0171..605033f997db 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderUserListActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderUserListActivity.java @@ -2,6 +2,8 @@ import android.os.Bundle; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.widget.Toolbar; import androidx.recyclerview.widget.LinearLayoutManager; @@ -31,7 +33,7 @@ public class ReaderUserListActivity extends LocaleAwareActivity { private int mRestorePosition; @Override - protected void onCreate(Bundle savedInstanceState) { + protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.reader_activity_userlist); @@ -67,7 +69,7 @@ protected void onCreate(Bundle savedInstanceState) { } @Override - protected void onSaveInstanceState(Bundle outState) { + protected void onSaveInstanceState(@NonNull Bundle outState) { int position = ((LinearLayoutManager) mRecyclerView.getLayoutManager()).findFirstVisibleItemPosition(); if (position > 0) { outState.putInt(ReaderConstants.KEY_RESTORE_POSITION, position); From 2a02c61493bc852562a3e14ee0e3dc32d10b4f8b Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Wed, 16 Aug 2023 17:26:56 +0300 Subject: [PATCH 44/59] Analysis: Add missing n-a to sdk override methods for reader video view FYI: 'n-a' stands for 'nullability annotations'. --- .../android/ui/reader/ReaderVideoViewerActivity.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderVideoViewerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderVideoViewerActivity.java index 2b6703c4a3dd..1ab5369dbfa6 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderVideoViewerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderVideoViewerActivity.java @@ -7,6 +7,7 @@ import android.widget.ProgressBar; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import org.wordpress.android.R; import org.wordpress.android.WordPress; @@ -22,7 +23,7 @@ public class ReaderVideoViewerActivity extends LocaleAwareActivity { private ProgressBar mProgress; @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.reader_activity_video_player); @@ -37,7 +38,8 @@ public void onCreate(Bundle savedInstanceState) { mWebView, org.wordpress.android.editor.R.drawable.media_movieclip ) { - public void onProgressChanged(WebView view, int progress) { + @Override + public void onProgressChanged(@NonNull WebView view, int progress) { if (progress == 100) { mProgress.setVisibility(View.GONE); } else { From ec1c0b8ca35f340610846cb6ec3f109055df1927 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Wed, 16 Aug 2023 17:37:47 +0300 Subject: [PATCH 45/59] Analysis: Add missing n-a to sdk override methods for stock media picker FYI: 'n-a' stands for 'nullability annotations'. --- .../stockmedia/StockMediaPickerActivity.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stockmedia/StockMediaPickerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/stockmedia/StockMediaPickerActivity.java index 0263965510b2..36e7100a10a1 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stockmedia/StockMediaPickerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/stockmedia/StockMediaPickerActivity.java @@ -186,7 +186,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { } mTextAdd.setOnClickListener(new View.OnClickListener() { - @Override public void onClick(View v) { + @Override + public void onClick(@NonNull View v) { if (null != mSite && mSite.hasDiskSpaceQuotaInformation() && mSite.getSpaceAvailable() <= 0) { ToastUtils.showToast(StockMediaPickerActivity.this, R.string.error_media_quota_exceeded_toast); return; @@ -197,7 +198,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { if (isMultiSelectEnabled()) { mTextPreview.setOnClickListener(new View.OnClickListener() { - @Override public void onClick(View v) { + @Override + public void onClick(@NonNull View v) { previewSelection(); } }); @@ -220,7 +222,7 @@ protected void onDestroy() { } @Override - protected void onSaveInstanceState(Bundle outState) { + protected void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); outState.putBoolean(KEY_IS_SHOWING_EMPTY_VIEW, mIsShowingEmptyView); @@ -262,7 +264,7 @@ public void onPause() { } @Override - public boolean onOptionsItemSelected(final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull final MenuItem item) { if (item.getItemId() == android.R.id.home) { setResult(RESULT_CANCELED); finish(); @@ -276,7 +278,7 @@ private boolean isMultiSelectEnabled() { } @Override - public boolean onQueryTextSubmit(String query) { + public boolean onQueryTextSubmit(@NonNull String query) { if (mSearchView != null) { mSearchView.clearFocus(); } @@ -285,7 +287,7 @@ public boolean onQueryTextSubmit(String query) { } @Override - public boolean onQueryTextChange(String query) { + public boolean onQueryTextChange(@NonNull String query) { if (!StringUtils.equals(query, mSearchQuery)) { submitSearch(query, true); } @@ -297,7 +299,8 @@ private void configureSearchView() { // don't allow the SearchView to be closed mSearchView.setOnCloseListener(new SearchView.OnCloseListener() { - @Override public boolean onClose() { + @Override + public boolean onClose() { return true; } }); @@ -492,7 +495,8 @@ private void showSelectionBar(final boolean show) { // sure the bar doesn't overlap the bottom row when showing long msDelay = AniUtils.Duration.SHORT.toMillis(this); mHandler.postDelayed(new Runnable() { - @Override public void run() { + @Override + public void run() { if (!isFinishing()) { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mRecycler.getLayoutParams(); if (show) { @@ -765,7 +769,7 @@ class StockViewHolder extends RecyclerView.ViewHolder { mImageView.setOnClickListener(new View.OnClickListener() { @Override - public void onClick(View v) { + public void onClick(@NonNull View v) { int position = getBindingAdapterPosition(); if (mAdapter.isValidPosition(position)) { mAdapter.toggleItemSelected(StockViewHolder.this, position); @@ -775,7 +779,7 @@ public void onClick(View v) { mImageView.setOnLongClickListener(new View.OnLongClickListener() { @Override - public boolean onLongClick(View v) { + public boolean onLongClick(@NonNull View v) { int position = getAdapterPosition(); if (mAdapter.isValidPosition(position)) { MediaPreviewActivity.showPreview(v.getContext(), mSite, mAdapter.mItems.get(position).getUrl()); From 37b13685dac893f9caa7824d8400a2de244f22f6 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Wed, 16 Aug 2023 17:43:10 +0300 Subject: [PATCH 46/59] Analysis: Add missing n-a to sdk override methods for theme browser FYI: 'n-a' stands for 'nullability annotations'. --- .../android/ui/themes/ThemeBrowserActivity.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/themes/ThemeBrowserActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/themes/ThemeBrowserActivity.java index e4e04a7e777f..a2dccec7b4cb 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/themes/ThemeBrowserActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/themes/ThemeBrowserActivity.java @@ -10,6 +10,7 @@ import androidx.activity.OnBackPressedCallback; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.widget.Toolbar; @@ -77,7 +78,7 @@ public class ThemeBrowserActivity extends LocaleAwareActivity implements ThemeBr @Inject UiHelpers mUiHelpers; @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDispatcher.register(this); @@ -140,7 +141,7 @@ protected void onSaveInstanceState(@NonNull Bundle outState) { } @Override - public boolean onOptionsItemSelected(MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { int i = item.getItemId(); if (i == android.R.id.home) { getOnBackPressedDispatcher().onBackPressed(); @@ -151,7 +152,7 @@ public boolean onOptionsItemSelected(MenuItem item) { } @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == ACTIVATE_THEME && resultCode == RESULT_OK && data != null) { String themeId = data.getStringExtra(THEME_ID); @@ -244,7 +245,7 @@ private void initJetpackBannerAnimation(View banner, HeaderGridView scrollableVi private boolean mIsScrollAtTop = true; @Override - public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) { + public void onScrollChange(@NonNull View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) { int scrollOffset = scrollableView.computeVerticalScrollOffset(); if (scrollOffset == 0 && !mIsScrollAtTop) { From dd8c1bb5f963882e50ffcd1d1bc90c0cfdc5e707 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 17 Aug 2023 14:04:08 +0300 Subject: [PATCH 47/59] Refactor: Remove final keyword from item on options item selected method This is done so as to have the 'onOptionsItemSelected(...)' method match the super method signature. --- .../org/wordpress/android/ui/AddQuickPressShortcutActivity.java | 2 +- .../java/org/wordpress/android/ui/AppLogViewerActivity.java | 2 +- .../main/java/org/wordpress/android/ui/WPWebViewActivity.java | 2 +- .../src/main/java/org/wordpress/android/ui/WebViewActivity.java | 2 +- .../org/wordpress/android/ui/comments/EditCommentActivity.java | 2 +- .../java/org/wordpress/android/ui/main/SitePickerActivity.java | 2 +- .../wordpress/android/ui/people/PeopleManagementActivity.java | 2 +- .../wordpress/android/ui/photopicker/PhotoPickerActivity.java | 2 +- .../org/wordpress/android/ui/plugins/PluginBrowserActivity.java | 2 +- .../org/wordpress/android/ui/plugins/PluginDetailActivity.java | 2 +- .../java/org/wordpress/android/ui/posts/EditPostActivity.java | 2 +- .../wordpress/android/ui/posts/PostSettingsTagsActivity.java | 2 +- .../wordpress/android/ui/posts/SelectCategoriesActivity.java | 2 +- .../org/wordpress/android/ui/prefs/AccountSettingsActivity.java | 2 +- .../java/org/wordpress/android/ui/prefs/MyProfileActivity.java | 2 +- .../android/ui/prefs/SiteSettingsTagDetailFragment.java | 2 +- .../wordpress/android/ui/prefs/SiteSettingsTagListActivity.java | 2 +- .../wordpress/android/ui/publicize/PublicizeListActivity.java | 2 +- .../wordpress/android/ui/reader/ReaderPostPagerActivity.java | 2 +- .../android/ui/stockmedia/StockMediaPickerActivity.java | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/AddQuickPressShortcutActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/AddQuickPressShortcutActivity.java index 0074ebc06b72..9f8f112b8f05 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/AddQuickPressShortcutActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/AddQuickPressShortcutActivity.java @@ -71,7 +71,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) { } @Override - public boolean onOptionsItemSelected(@NonNull final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { if (item.getItemId() == android.R.id.home) { getOnBackPressedDispatcher().onBackPressed(); return true; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/AppLogViewerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/AppLogViewerActivity.java index 4c9e336f4cdd..fe9b929a32f7 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/AppLogViewerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/AppLogViewerActivity.java @@ -148,7 +148,7 @@ public boolean onCreateOptionsMenu(@NonNull Menu menu) { @Override @SuppressLint("NonConstantResourceId") - public boolean onOptionsItemSelected(@NonNull final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { switch (item.getItemId()) { case android.R.id.home: finish(); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/WPWebViewActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/WPWebViewActivity.java index 8c014b1c45d6..89bff2a5cc50 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/WPWebViewActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/WPWebViewActivity.java @@ -863,7 +863,7 @@ public boolean onCreateOptionsMenu(@NonNull Menu menu) { } @Override - public boolean onOptionsItemSelected(@NonNull final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { if (mWebView == null) { return false; } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/WebViewActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/WebViewActivity.java index 30210e2e070b..82f98cdb80fe 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/WebViewActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/WebViewActivity.java @@ -163,7 +163,7 @@ public void loadUrl(String url, Map additionalHttpHeaders) { } @Override - public boolean onOptionsItemSelected(@NonNull final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { if (item.getItemId() == android.R.id.home) { cancel(); finish(); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/comments/EditCommentActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/comments/EditCommentActivity.java index 497091150082..1ffc5f7bfff3 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/comments/EditCommentActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/comments/EditCommentActivity.java @@ -207,7 +207,7 @@ public boolean onCreateOptionsMenu(@NonNull Menu menu) { } @Override - public boolean onOptionsItemSelected(@NonNull final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { int i = item.getItemId(); if (i == android.R.id.home) { getOnBackPressedDispatcher().onBackPressed(); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java index 9cf20b075509..07a762003a86 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java @@ -279,7 +279,7 @@ private void updateMenuItemVisibility() { } @Override - public boolean onOptionsItemSelected(@NonNull final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { int itemId = item.getItemId(); if (itemId == android.R.id.home) { AnalyticsTracker.track(Stat.SITE_SWITCHER_DISMISSED); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleManagementActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleManagementActivity.java index c5d1a4afa162..792945a02283 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleManagementActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/people/PeopleManagementActivity.java @@ -232,7 +232,7 @@ public void onStop() { } @Override - public boolean onOptionsItemSelected(@NonNull final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { if (item.getItemId() == android.R.id.home) { getOnBackPressedDispatcher().onBackPressed(); return true; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/photopicker/PhotoPickerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/photopicker/PhotoPickerActivity.java index f57454d6bf7f..f0b2a2d93a07 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/photopicker/PhotoPickerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/photopicker/PhotoPickerActivity.java @@ -165,7 +165,7 @@ protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) { } @Override - public boolean onOptionsItemSelected(@NonNull final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { if (item.getItemId() == android.R.id.home) { setResult(RESULT_CANCELED); finish(); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginBrowserActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginBrowserActivity.java index dfcb8dcfa8ec..cded9e5782e7 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginBrowserActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginBrowserActivity.java @@ -236,7 +236,7 @@ public boolean onCreateOptionsMenu(@NonNull Menu menu) { } @Override - public boolean onOptionsItemSelected(@NonNull final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { if (item.getItemId() == android.R.id.home) { getOnBackPressedDispatcher().onBackPressed(); return true; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginDetailActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginDetailActivity.java index 8533fcbb8cc9..5eacd494ea07 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginDetailActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginDetailActivity.java @@ -406,7 +406,7 @@ public boolean onPrepareOptionsMenu(@NonNull Menu menu) { } @Override - public boolean onOptionsItemSelected(@NonNull final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { if (item.getItemId() == android.R.id.home) { if (isPluginStateChangedSinceLastConfigurationDispatch()) { // It looks like we have some unsaved changes, we need to force a configuration dispatch since the diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java index 50bcaf70e8e6..a47ca374b3a1 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java @@ -1578,7 +1578,7 @@ public void notifyEmptyPost() { // Menu actions @Override - public boolean onOptionsItemSelected(@NonNull final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { int itemId = item.getItemId(); if (itemId == android.R.id.home) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostSettingsTagsActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostSettingsTagsActivity.java index d20e83dfe104..b4f4da0c784d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostSettingsTagsActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostSettingsTagsActivity.java @@ -79,7 +79,7 @@ protected void onSaveInstanceState(@NonNull Bundle outState) { } @Override - public boolean onOptionsItemSelected(@NonNull final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { int itemId = item.getItemId(); if (itemId == android.R.id.home) { saveAndFinish(); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/SelectCategoriesActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/SelectCategoriesActivity.java index 56ca22954e1a..2b68ee6e4b1f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/SelectCategoriesActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/SelectCategoriesActivity.java @@ -229,7 +229,7 @@ public void categoryAdded(TermModel newCategory) { } @Override - public boolean onOptionsItemSelected(@NonNull final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { int itemId = item.getItemId(); if (itemId == R.id.menu_new_category) { if (NetworkUtils.checkConnection(this)) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AccountSettingsActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AccountSettingsActivity.java index c500ad105cf8..4905c930cea7 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AccountSettingsActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AccountSettingsActivity.java @@ -32,7 +32,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) { } @Override - public boolean onOptionsItemSelected(@NonNull final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { if (item.getItemId() == android.R.id.home) { getOnBackPressedDispatcher().onBackPressed(); return true; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/MyProfileActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/MyProfileActivity.java index c2f700e4126e..764528c999e2 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/MyProfileActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/MyProfileActivity.java @@ -39,7 +39,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) { } @Override - public boolean onOptionsItemSelected(@NonNull final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { if (item.getItemId() == android.R.id.home) { getOnBackPressedDispatcher().onBackPressed(); return true; 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..211589a6c367 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 @@ -108,7 +108,7 @@ public void onPrepareOptionsMenu(Menu menu) { } @Override - public boolean onOptionsItemSelected(final MenuItem item) { + public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.menu_trash && mListener != null) { mListener.onRequestDeleteTag(mTerm); return true; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTagListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTagListActivity.java index 2033843326f6..777117ca85e5 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTagListActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTagListActivity.java @@ -234,7 +234,7 @@ public boolean onCreateOptionsMenu(@NonNull Menu menu) { } @Override - public boolean onOptionsItemSelected(@NonNull final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { if (item.getItemId() == android.R.id.home) { getOnBackPressedDispatcher().onBackPressed(); return true; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeListActivity.java index 9e181713ec01..cabf9cd2ef6b 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeListActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/publicize/PublicizeListActivity.java @@ -217,7 +217,7 @@ private void closeWebViewFragment() { } @Override - public boolean onOptionsItemSelected(@NonNull final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { int itemId = item.getItemId(); if (itemId == android.R.id.home) { getOnBackPressedDispatcher().onBackPressed(); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java index eb7d6759b6af..6e79930c4885 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostPagerActivity.java @@ -660,7 +660,7 @@ protected void onPause() { } @Override - public boolean onOptionsItemSelected(@NonNull final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { if (item.getItemId() == android.R.id.home) { finish(); return true; diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stockmedia/StockMediaPickerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/stockmedia/StockMediaPickerActivity.java index 36e7100a10a1..779040acecaf 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stockmedia/StockMediaPickerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/stockmedia/StockMediaPickerActivity.java @@ -264,7 +264,7 @@ public void onPause() { } @Override - public boolean onOptionsItemSelected(@NonNull final MenuItem item) { + public boolean onOptionsItemSelected(@NonNull MenuItem item) { if (item.getItemId() == android.R.id.home) { setResult(RESULT_CANCELED); finish(); From 0b7aded466d6f9003cb154e16ffdc5a802e13ee3 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 17 Aug 2023 14:16:08 +0300 Subject: [PATCH 48/59] Refactor: Rename menu item param to item on on menu item action expand This is done so as to have the 'onMenuItemActionExpand(...)' method match the super method signature. --- .../wordpress/android/ui/plugins/PluginBrowserActivity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginBrowserActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginBrowserActivity.java index cded9e5782e7..6f57dff2dbfb 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginBrowserActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginBrowserActivity.java @@ -328,14 +328,14 @@ private void showProgress(boolean show) { } @Override - public boolean onMenuItemActionExpand(@NonNull MenuItem menuItem) { + public boolean onMenuItemActionExpand(@NonNull MenuItem item) { showListFragment(PluginListType.SEARCH); mSearchView.setOnQueryTextListener(this); return true; } @Override - public boolean onMenuItemActionCollapse(@NonNull MenuItem menuItem) { + public boolean onMenuItemActionCollapse(@NonNull MenuItem item) { mSearchView.setOnQueryTextListener(null); hideListFragment(); mViewModel.setSearchQuery(""); From 8405c3b98119fab5e69a40f85943fc0cc4527151 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 17 Aug 2023 15:22:29 +0300 Subject: [PATCH 49/59] Refactor: Change modifier to protected on on activity result method This is done so as to have the 'onActivityResult(...)' method match the super method signature. --- .../main/java/org/wordpress/android/ui/main/WPMainActivity.java | 2 +- .../org/wordpress/android/ui/media/MediaBrowserActivity.java | 2 +- .../java/org/wordpress/android/ui/posts/EditPostActivity.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java index e955c947fec3..ecd44b2728d9 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java @@ -1311,7 +1311,7 @@ private void setSite(Intent data) { @Override @SuppressWarnings("deprecation") - public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); if (!mSelectedSiteRepository.hasSelectedSite()) { initSelectedSite(); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java index 0e1081cfdd54..99bfaead0a39 100755 --- a/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/media/MediaBrowserActivity.java @@ -495,7 +495,7 @@ private void checkRecordedVideoDurationBeforeUploadAndTrack() { } @Override - public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java index a47ca374b3a1..93051edf337f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java @@ -2786,7 +2786,7 @@ private void setPageContent() { @Override @SuppressWarnings("deprecation") - public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); // In case of Remote Preview we need to change state even if (resultCode != Activity.RESULT_OK) From 5a7504ab346590cf1b15eca34c054e960b2f0d1e Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 17 Aug 2023 15:26:51 +0300 Subject: [PATCH 50/59] Refactor: Rename s param to query on on query text submit method This is done so as to have the 'onQueryTextSubmit(...)' method match the super method signature. --- .../java/org/wordpress/android/ui/main/SitePickerActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java index 07a762003a86..9800db065317 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java @@ -664,7 +664,7 @@ public void onSiteClick(SiteRecord siteRecord) { } @Override - public boolean onQueryTextSubmit(@NonNull String s) { + public boolean onQueryTextSubmit(@NonNull String query) { hideSoftKeyboard(); return true; } From 922e9d96fd3b9649205ff1541fb09cb3a26b826e Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 17 Aug 2023 15:29:01 +0300 Subject: [PATCH 51/59] Refactor: Rename s param to new text on on query text change method This is done so as to have the 'onQueryTextChange(...)' method match the super method signature. --- .../org/wordpress/android/ui/main/SitePickerActivity.java | 6 +++--- .../wordpress/android/ui/plugins/PluginBrowserActivity.java | 4 ++-- .../android/ui/prefs/SiteSettingsTagListActivity.java | 4 ++-- .../android/ui/stockmedia/StockMediaPickerActivity.java | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java index 9800db065317..8e383ecb82a0 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java @@ -670,11 +670,11 @@ public boolean onQueryTextSubmit(@NonNull String query) { } @Override - public boolean onQueryTextChange(@NonNull String s) { + public boolean onQueryTextChange(@NonNull String newText) { if (getAdapter().getIsInSearchMode()) { AnalyticsTracker.track(Stat.SITE_SWITCHER_SEARCH_PERFORMED); - getAdapter().setLastSearch(s); - getAdapter().searchSites(s); + getAdapter().setLastSearch(newText); + getAdapter().searchSites(newText); } return true; } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginBrowserActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginBrowserActivity.java index 6f57dff2dbfb..6db245f9df0d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginBrowserActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/plugins/PluginBrowserActivity.java @@ -296,8 +296,8 @@ public boolean onQueryTextSubmit(@NonNull String query) { } @Override - public boolean onQueryTextChange(@NonNull String query) { - mViewModel.setSearchQuery(query); + public boolean onQueryTextChange(@NonNull String newText) { + mViewModel.setSearchQuery(newText); return true; } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTagListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTagListActivity.java index 777117ca85e5..021d4beb4df2 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTagListActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTagListActivity.java @@ -362,8 +362,8 @@ public boolean onQueryTextSubmit(@NonNull String query) { } @Override - public boolean onQueryTextChange(@NonNull String query) { - mAdapter.filter(query); + public boolean onQueryTextChange(@NonNull String newText) { + mAdapter.filter(newText); return false; } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stockmedia/StockMediaPickerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/stockmedia/StockMediaPickerActivity.java index 779040acecaf..79aea2b55ae3 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stockmedia/StockMediaPickerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/stockmedia/StockMediaPickerActivity.java @@ -287,9 +287,9 @@ public boolean onQueryTextSubmit(@NonNull String query) { } @Override - public boolean onQueryTextChange(@NonNull String query) { - if (!StringUtils.equals(query, mSearchQuery)) { - submitSearch(query, true); + public boolean onQueryTextChange(@NonNull String newText) { + if (!StringUtils.equals(newText, mSearchQuery)) { + submitSearch(newText, true); } return true; } From 0acc778c3e22eb2374d448c328ac4ca4df9483f8 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 17 Aug 2023 15:30:23 +0300 Subject: [PATCH 52/59] Refactor: Rename action mode param to mode on on create action mode This is done so as to have the 'onCreateActionMode(...)' method match the super method signature. --- .../org/wordpress/android/ui/main/SitePickerActivity.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java index 8e383ecb82a0..63a729902770 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java @@ -731,12 +731,12 @@ private final class ActionModeCallback implements ActionMode.Callback { private Set mChangeSet; @Override - public boolean onCreateActionMode(@NonNull ActionMode actionMode, @NonNull Menu menu) { - mActionMode = actionMode; + public boolean onCreateActionMode(@NonNull ActionMode mode, @NonNull Menu menu) { + mActionMode = mode; mHasChanges = false; mChangeSet = new HashSet<>(); updateActionModeTitle(); - actionMode.getMenuInflater().inflate(R.menu.site_picker_action_mode, menu); + mode.getMenuInflater().inflate(R.menu.site_picker_action_mode, menu); return true; } From 6068d3a305653b5b9d0558c0dbebb0c7c7886a5b Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 17 Aug 2023 15:31:16 +0300 Subject: [PATCH 53/59] Refactor: Rename action mode param to mode on on prepare action mode This is done so as to have the 'onPrepareActionMode(...)' method match the super method signature. --- .../java/org/wordpress/android/ui/main/SitePickerActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java index 63a729902770..7f76d7cf15a9 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java @@ -741,7 +741,7 @@ public boolean onCreateActionMode(@NonNull ActionMode mode, @NonNull Menu menu) } @Override - public boolean onPrepareActionMode(@NonNull ActionMode actionMode, @NonNull Menu menu) { + public boolean onPrepareActionMode(@NonNull ActionMode mode, @NonNull Menu menu) { MenuItem mnuShow = menu.findItem(R.id.menu_show); mnuShow.setEnabled(mShowMenuEnabled); From 83b9261d73c07d227ed6ee2df79b7f843d85ed7a Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 17 Aug 2023 15:31:55 +0300 Subject: [PATCH 54/59] Refactor: Rename action mode param to mode on on action item clicked This is done so as to have the 'onActionItemClicked(...)' method match the super method signature. --- .../java/org/wordpress/android/ui/main/SitePickerActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java index 7f76d7cf15a9..7b097adadefd 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java @@ -758,7 +758,7 @@ public boolean onPrepareActionMode(@NonNull ActionMode mode, @NonNull Menu menu) } @Override - public boolean onActionItemClicked(@NonNull ActionMode actionMode, @NonNull MenuItem menuItem) { + public boolean onActionItemClicked(@NonNull ActionMode mode, @NonNull MenuItem menuItem) { int itemId = menuItem.getItemId(); if (itemId == R.id.menu_show) { Set changeSet = getAdapter().setVisibilityForSelectedSites(true); From 975642ea9072e7c158a4955af49f2e00a68d30e0 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 17 Aug 2023 15:32:29 +0300 Subject: [PATCH 55/59] Refactor: Rename menu item param to item on on action item clicked This is done so as to have the 'onActionItemClicked(...)' method match the super method signature. --- .../org/wordpress/android/ui/main/SitePickerActivity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java index 7b097adadefd..2c67688a3f47 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java @@ -758,8 +758,8 @@ public boolean onPrepareActionMode(@NonNull ActionMode mode, @NonNull Menu menu) } @Override - public boolean onActionItemClicked(@NonNull ActionMode mode, @NonNull MenuItem menuItem) { - int itemId = menuItem.getItemId(); + public boolean onActionItemClicked(@NonNull ActionMode mode, @NonNull MenuItem item) { + int itemId = item.getItemId(); if (itemId == R.id.menu_show) { Set changeSet = getAdapter().setVisibilityForSelectedSites(true); mChangeSet.addAll(changeSet); From 15fefd747f3247beb0e8e12174d2921b14ad0c69 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 17 Aug 2023 15:33:19 +0300 Subject: [PATCH 56/59] Refactor: Rename action mode param to mode on on destroy action mode This is done so as to have the 'onDestroyActionMode(...)' method match the super method signature. --- .../java/org/wordpress/android/ui/main/SitePickerActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java index 2c67688a3f47..788b3e502fc9 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java @@ -779,7 +779,7 @@ public boolean onActionItemClicked(@NonNull ActionMode mode, @NonNull MenuItem i } @Override - public void onDestroyActionMode(@NonNull ActionMode actionMode) { + public void onDestroyActionMode(@NonNull ActionMode mode) { if (mHasChanges) { saveSitesVisibility(mChangeSet); } From a452dbf8dc5587ea67d37cf8f73925fc2291179e Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 17 Aug 2023 15:36:59 +0300 Subject: [PATCH 57/59] Refactor: Remove final keyword from item on on bind viewHolder method This is done so as to have the 'onBindViewHolder(...)' method match the super method signature. --- .../wordpress/android/ui/prefs/SiteSettingsTagListActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTagListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTagListActivity.java index 021d4beb4df2..ce9218765e42 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTagListActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/SiteSettingsTagListActivity.java @@ -461,7 +461,7 @@ public TagViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) } @Override - public void onBindViewHolder(@NonNull final TagListAdapter.TagViewHolder holder, int position) { + public void onBindViewHolder(@NonNull TagListAdapter.TagViewHolder holder, int position) { TermModel term = mFilteredTags.get(position); holder.mTxtTag.setText(StringEscapeUtils.unescapeHtml4(term.getName())); if (term.getPostCount() > 0) { From 00af6b7a57dd3e96a1e4b4d74e4ecb4aa77e60e0 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 17 Aug 2023 15:48:04 +0300 Subject: [PATCH 58/59] Refactor: Make intent non null on on new intent function for kotlin This is done so as to have the 'onNewIntent(...)' function for Kotlin files match the 'onNewIntent(...)' method for Java files. Otherwsie, half of those files were using 'intent' as nullable and the other half were using 'intent' as non null, which creates confusion. --- .../android/ui/jetpack/scan/ScanActivity.kt | 6 ++---- .../android/ui/jetpack/scan/ScanFragment.kt | 16 +++++++--------- .../android/ui/stats/refresh/StatsActivity.kt | 10 ++++------ 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/jetpack/scan/ScanActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/jetpack/scan/ScanActivity.kt index 219a59b936c8..52aa2cb08df2 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/jetpack/scan/ScanActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/jetpack/scan/ScanActivity.kt @@ -31,11 +31,9 @@ class ScanActivity : AppCompatActivity(), ScrollableViewInitializedListener { private var binding: ScanActivityBinding? = null - override fun onNewIntent(intent: Intent?) { + override fun onNewIntent(intent: Intent) { super.onNewIntent(intent) - (supportFragmentManager.findFragmentById(R.id.fragment_container_view) as? ScanFragment)?.let { - it.onNewIntent(intent) - } + (supportFragmentManager.findFragmentById(R.id.fragment_container_view) as? ScanFragment)?.onNewIntent(intent) } override fun onCreate(savedInstanceState: Bundle?) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/jetpack/scan/ScanFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/jetpack/scan/ScanFragment.kt index 305967806c9c..07600665330c 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/jetpack/scan/ScanFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/jetpack/scan/ScanFragment.kt @@ -192,15 +192,13 @@ class ScanFragment : Fragment(R.layout.scan_fragment) { super.onSaveInstanceState(outState) } - fun onNewIntent(intent: Intent?) { - intent?.let { - val threatId = intent.getLongExtra(ScanActivity.REQUEST_FIX_STATE, 0L) - val messageRes = intent.getIntExtra(ScanActivity.REQUEST_SCAN_STATE, 0) - if (threatId > 0L) { - viewModel.onFixStateRequested(threatId) - } else if (messageRes > 0) { - viewModel.onScanStateRequestedWithMessage(messageRes) - } + fun onNewIntent(intent: Intent) { + val threatId = intent.getLongExtra(ScanActivity.REQUEST_FIX_STATE, 0L) + val messageRes = intent.getIntExtra(ScanActivity.REQUEST_SCAN_STATE, 0) + if (threatId > 0L) { + viewModel.onFixStateRequested(threatId) + } else if (messageRes > 0) { + viewModel.onScanStateRequestedWithMessage(messageRes) } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsActivity.kt index 231febf505cb..2aaa415a22e9 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsActivity.kt @@ -50,12 +50,10 @@ class StatsActivity : LocaleAwareActivity() { return super.onOptionsItemSelected(item) } - override fun onNewIntent(intent: Intent?) { - intent?.let { - val siteId = intent.getIntExtra(WordPress.LOCAL_SITE_ID, -1) - if (siteId > -1) { - viewModel.start(intent, restart = true) - } + override fun onNewIntent(intent: Intent) { + val siteId = intent.getIntExtra(WordPress.LOCAL_SITE_ID, -1) + if (siteId > -1) { + viewModel.start(intent, restart = true) } super.onNewIntent(intent) } From 4886871dec53d09b4ce7484bc699f31b8b045559 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Thu, 17 Aug 2023 15:58:43 +0300 Subject: [PATCH 59/59] Refactor: Rename view param to v on on click method This is done so as to have the 'onClick(...)' method match the super method signature. --- .../org/wordpress/android/ui/reader/ReaderPostListActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java index 0ff8a3cdb784..30aa33343cef 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/ReaderPostListActivity.java @@ -108,7 +108,7 @@ public void handleOnBackPressed() { } toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override - public void onClick(@NonNull View view) { + public void onClick(@NonNull View v) { finish(); } });