From 816991c172dd9bcad41ba05040efea5b00834ae7 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Sat, 26 Oct 2019 04:20:27 +0200 Subject: [PATCH 1/4] codacy: avoid unused imports Signed-off-by: Andy Scherzinger --- src/main/java/com/owncloud/android/jobs/AccountRemovalJob.java | 1 - .../com/owncloud/android/ui/activity/FolderPickerActivity.java | 1 - .../android/ui/fragment/contactsbackup/ContactListFragment.java | 1 - src/main/java/com/owncloud/android/utils/FilesSyncHelper.java | 2 -- 4 files changed, 5 deletions(-) diff --git a/src/main/java/com/owncloud/android/jobs/AccountRemovalJob.java b/src/main/java/com/owncloud/android/jobs/AccountRemovalJob.java index 6cb7bbe977..b87d3e99de 100644 --- a/src/main/java/com/owncloud/android/jobs/AccountRemovalJob.java +++ b/src/main/java/com/owncloud/android/jobs/AccountRemovalJob.java @@ -28,7 +28,6 @@ import android.accounts.Account; import android.accounts.AccountManager; import android.accounts.AccountManagerCallback; import android.accounts.AccountManagerFuture; -import android.content.ContentResolver; import android.content.Context; import android.net.Uri; import android.os.Build; diff --git a/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.java b/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.java index 6f6d13fc5c..021f93d211 100644 --- a/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.java @@ -19,7 +19,6 @@ package com.owncloud.android.ui.activity; -import android.accounts.Account; import android.accounts.AuthenticatorException; import android.app.Activity; import android.content.BroadcastReceiver; diff --git a/src/main/java/com/owncloud/android/ui/fragment/contactsbackup/ContactListFragment.java b/src/main/java/com/owncloud/android/ui/fragment/contactsbackup/ContactListFragment.java index bd7d6af038..11c0894716 100644 --- a/src/main/java/com/owncloud/android/ui/fragment/contactsbackup/ContactListFragment.java +++ b/src/main/java/com/owncloud/android/ui/fragment/contactsbackup/ContactListFragment.java @@ -89,7 +89,6 @@ import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.List; -import java.util.Objects; import java.util.Set; import javax.inject.Inject; diff --git a/src/main/java/com/owncloud/android/utils/FilesSyncHelper.java b/src/main/java/com/owncloud/android/utils/FilesSyncHelper.java index 7f637a5a9e..9116a3d570 100644 --- a/src/main/java/com/owncloud/android/utils/FilesSyncHelper.java +++ b/src/main/java/com/owncloud/android/utils/FilesSyncHelper.java @@ -64,8 +64,6 @@ import java.io.IOException; import java.util.Set; import java.util.concurrent.TimeUnit; -import androidx.annotation.RequiresApi; - import static com.owncloud.android.datamodel.OCFile.PATH_SEPARATOR; /** From 1d3fca653fa9007aabcfb13e67b0e8834cc3204a Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Sat, 26 Oct 2019 04:22:34 +0200 Subject: [PATCH 2/4] codacy: Avoid declaring a variable if it is unreferenced before a possible exit point. Signed-off-by: Andy Scherzinger --- .../owncloud/android/providers/DocumentsStorageProvider.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/owncloud/android/providers/DocumentsStorageProvider.java b/src/main/java/com/owncloud/android/providers/DocumentsStorageProvider.java index 528ca56a98..b7f426f6f1 100644 --- a/src/main/java/com/owncloud/android/providers/DocumentsStorageProvider.java +++ b/src/main/java/com/owncloud/android/providers/DocumentsStorageProvider.java @@ -303,13 +303,13 @@ public class DocumentsStorageProvider extends DocumentsProvider { throws FileNotFoundException { Log.d(TAG, "openDocumentThumbnail(), id=" + documentId); - Document document = toDocument(documentId); - Context context = getContext(); if (context == null) { throw new FileNotFoundException("Context may not be null!"); } + Document document = toDocument(documentId); + boolean exists = ThumbnailsCacheManager.containsBitmap(ThumbnailsCacheManager.PREFIX_THUMBNAIL + document.getFile().getRemoteId()); From a6fdec865678a93efb38e2d47365bca8de00593f Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Sat, 26 Oct 2019 04:33:03 +0200 Subject: [PATCH 3/4] shorten method Signed-off-by: Andy Scherzinger --- .../ui/activity/ExternalSiteWebView.java | 74 ++++++++++--------- 1 file changed, 40 insertions(+), 34 deletions(-) diff --git a/src/main/java/com/owncloud/android/ui/activity/ExternalSiteWebView.java b/src/main/java/com/owncloud/android/ui/activity/ExternalSiteWebView.java index 9d75c42c97..3820d5c632 100644 --- a/src/main/java/com/owncloud/android/ui/activity/ExternalSiteWebView.java +++ b/src/main/java/com/owncloud/android/ui/activity/ExternalSiteWebView.java @@ -93,7 +93,6 @@ public class ExternalSiteWebView extends FileActivity { webview.setFocusableInTouchMode(true); webview.setClickable(true); - // allow debugging (when building the debug version); see details in // https://developers.google.com/web/tools/chrome-devtools/remote-debugging/webviews if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && @@ -114,39 +113,8 @@ public class ExternalSiteWebView extends FileActivity { setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); } - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - ThemeUtils.setColoredTitle(actionBar, title, this); - - if (showSidebar) { - actionBar.setDisplayHomeAsUpEnabled(true); - } else { - setDrawerIndicatorEnabled(false); - } - } - - // enable zoom - webSettings.setSupportZoom(true); - webSettings.setBuiltInZoomControls(true); - webSettings.setDisplayZoomControls(false); - - // Non-responsive webs are zoomed out when loaded - webSettings.setUseWideViewPort(true); - webSettings.setLoadWithOverviewMode(true); - - // user agent - webSettings.setUserAgentString(MainApp.getUserAgent()); - - // no private data storing - webSettings.setSavePassword(false); - webSettings.setSaveFormData(false); - - // disable local file access - webSettings.setAllowFileAccess(false); - - // enable javascript - webSettings.setJavaScriptEnabled(true); - webSettings.setDomStorageEnabled(true); + setupActionBar(title); + setupWebSettings(webSettings); final ProgressBar progressBar = findViewById(R.id.progressBar); @@ -172,6 +140,44 @@ public class ExternalSiteWebView extends FileActivity { webview.loadUrl(url); } + private void setupWebSettings(WebSettings webSettings) { + // enable zoom + webSettings.setSupportZoom(true); + webSettings.setBuiltInZoomControls(true); + webSettings.setDisplayZoomControls(false); + + // Non-responsive webs are zoomed out when loaded + webSettings.setUseWideViewPort(true); + webSettings.setLoadWithOverviewMode(true); + + // user agent + webSettings.setUserAgentString(MainApp.getUserAgent()); + + // no private data storing + webSettings.setSavePassword(false); + webSettings.setSaveFormData(false); + + // disable local file access + webSettings.setAllowFileAccess(false); + + // enable javascript + webSettings.setJavaScriptEnabled(true); + webSettings.setDomStorageEnabled(true); + } + + private void setupActionBar(String title) { + ActionBar actionBar = getSupportActionBar(); + if (actionBar != null) { + ThemeUtils.setColoredTitle(actionBar, title, this); + + if (showSidebar) { + actionBar.setDisplayHomeAsUpEnabled(true); + } else { + setDrawerIndicatorEnabled(false); + } + } + } + @Override public boolean onOptionsItemSelected(MenuItem item) { boolean retval; From 2bb13a1545d576ee02ef94696deeaa815a45aecf Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Sat, 26 Oct 2019 09:36:58 +0200 Subject: [PATCH 4/4] move suppress annotation to newly created method Signed-off-by: Andy Scherzinger --- .../com/owncloud/android/ui/activity/ExternalSiteWebView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/owncloud/android/ui/activity/ExternalSiteWebView.java b/src/main/java/com/owncloud/android/ui/activity/ExternalSiteWebView.java index 3820d5c632..3015c610dd 100644 --- a/src/main/java/com/owncloud/android/ui/activity/ExternalSiteWebView.java +++ b/src/main/java/com/owncloud/android/ui/activity/ExternalSiteWebView.java @@ -65,7 +65,6 @@ public class ExternalSiteWebView extends FileActivity { private boolean showSidebar; String url; - @SuppressLint("SetJavaScriptEnabled") @Override protected void onCreate(Bundle savedInstanceState) { Log_OC.v(TAG, "onCreate() start"); @@ -140,6 +139,7 @@ public class ExternalSiteWebView extends FileActivity { webview.loadUrl(url); } + @SuppressLint("SetJavaScriptEnabled") private void setupWebSettings(WebSettings webSettings) { // enable zoom webSettings.setSupportZoom(true);