Merge pull request #4733 from nextcloud/codacy

Codacy
This commit is contained in:
Tobias Kaminsky 2019-10-28 11:17:13 +01:00 committed by GitHub
commit 98487b501d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 42 deletions

View file

@ -28,7 +28,6 @@ import android.accounts.Account;
import android.accounts.AccountManager; import android.accounts.AccountManager;
import android.accounts.AccountManagerCallback; import android.accounts.AccountManagerCallback;
import android.accounts.AccountManagerFuture; import android.accounts.AccountManagerFuture;
import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;

View file

@ -303,13 +303,13 @@ public class DocumentsStorageProvider extends DocumentsProvider {
throws FileNotFoundException { throws FileNotFoundException {
Log.d(TAG, "openDocumentThumbnail(), id=" + documentId); Log.d(TAG, "openDocumentThumbnail(), id=" + documentId);
Document document = toDocument(documentId);
Context context = getContext(); Context context = getContext();
if (context == null) { if (context == null) {
throw new FileNotFoundException("Context may not be null!"); throw new FileNotFoundException("Context may not be null!");
} }
Document document = toDocument(documentId);
boolean exists = ThumbnailsCacheManager.containsBitmap(ThumbnailsCacheManager.PREFIX_THUMBNAIL boolean exists = ThumbnailsCacheManager.containsBitmap(ThumbnailsCacheManager.PREFIX_THUMBNAIL
+ document.getFile().getRemoteId()); + document.getFile().getRemoteId());

View file

@ -65,7 +65,6 @@ public class ExternalSiteWebView extends FileActivity {
private boolean showSidebar; private boolean showSidebar;
String url; String url;
@SuppressLint("SetJavaScriptEnabled")
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
Log_OC.v(TAG, "onCreate() start"); Log_OC.v(TAG, "onCreate() start");
@ -93,7 +92,6 @@ public class ExternalSiteWebView extends FileActivity {
webview.setFocusableInTouchMode(true); webview.setFocusableInTouchMode(true);
webview.setClickable(true); webview.setClickable(true);
// allow debugging (when building the debug version); see details in // allow debugging (when building the debug version); see details in
// https://developers.google.com/web/tools/chrome-devtools/remote-debugging/webviews // https://developers.google.com/web/tools/chrome-devtools/remote-debugging/webviews
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT &&
@ -114,39 +112,8 @@ public class ExternalSiteWebView extends FileActivity {
setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
} }
ActionBar actionBar = getSupportActionBar(); setupActionBar(title);
if (actionBar != null) { setupWebSettings(webSettings);
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);
final ProgressBar progressBar = findViewById(R.id.progressBar); final ProgressBar progressBar = findViewById(R.id.progressBar);
@ -172,6 +139,45 @@ public class ExternalSiteWebView extends FileActivity {
webview.loadUrl(url); webview.loadUrl(url);
} }
@SuppressLint("SetJavaScriptEnabled")
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 @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
boolean retval; boolean retval;

View file

@ -19,7 +19,6 @@
package com.owncloud.android.ui.activity; package com.owncloud.android.ui.activity;
import android.accounts.Account;
import android.accounts.AuthenticatorException; import android.accounts.AuthenticatorException;
import android.app.Activity; import android.app.Activity;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;

View file

@ -89,7 +89,6 @@ import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import javax.inject.Inject; import javax.inject.Inject;

View file

@ -64,8 +64,6 @@ import java.io.IOException;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import androidx.annotation.RequiresApi;
import static com.owncloud.android.datamodel.OCFile.PATH_SEPARATOR; import static com.owncloud.android.datamodel.OCFile.PATH_SEPARATOR;
/** /**