Эх сурвалжийг харах

Merge pull request #2005 from nextcloud/codacy

Codacy fixes
Andy Scherzinger 7 жил өмнө
parent
commit
d4b19e6ea6

+ 1 - 1
src/androidTest/java/com/owncloud/android/authentication/AuthenticatorActivityTest.java

@@ -96,7 +96,7 @@ public class AuthenticatorActivityTest {
     }
 
     @Test
-    public void check_login()
+    public void checkLogin()
         throws InterruptedException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
         Bundle arguments = InstrumentationRegistry.getArguments();
 

+ 0 - 12
src/androidTest/java/com/owncloud/android/uiautomator/InitialTest.java

@@ -131,18 +131,6 @@ public class InitialTest {
         return resolveInfo.activityInfo.packageName;
     }
 
-    /**
-     * Helper to click on objects that match the content-description text.
-     *
-     * @param description the description
-     * @throws UiObjectNotFoundException
-     */
-    private void clickByDescription(String description) throws UiObjectNotFoundException {
-        UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
-        UiObject obj = device.findObject(new UiSelector().description(description));
-        obj.clickAndWaitForNewWindow();
-    }
-
     /**
      * Helper to click on object that match the text value.
      *

+ 8 - 12
src/main/java/com/owncloud/android/media/MediaControlView.java

@@ -1,4 +1,4 @@
-/**
+/*
  * ownCloud Android client application
  *
  * @author David A. Velasco
@@ -55,12 +55,10 @@ import java.util.Locale;
  * It synchronizes itself with the state of the 
  * {@link MediaPlayer}.
  */
-
 public class MediaControlView extends FrameLayout /* implements OnLayoutChangeListener, OnTouchListener */ implements OnClickListener, OnSeekBarChangeListener {
     private static final String TAG = MediaControlView.class.getSimpleName();
 
     private MediaPlayerControl mPlayer;
-    private Context mContext;
     private View mRoot;
     private ProgressBar mProgress;
     private TextView mEndTime, mCurrentTime;
@@ -72,13 +70,12 @@ public class MediaControlView extends FrameLayout /* implements OnLayoutChangeLi
 
     public MediaControlView(Context context, AttributeSet attrs) {
         super(context, attrs);
-        mContext = context;
 
         FrameLayout.LayoutParams frameParams = new FrameLayout.LayoutParams(
                 ViewGroup.LayoutParams.MATCH_PARENT,
                 ViewGroup.LayoutParams.MATCH_PARENT
         );
-        LayoutInflater inflate = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+        LayoutInflater inflate = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
         mRoot = inflate.inflate(R.layout.media_control, null);
         initControllerView(mRoot);
         addView(mRoot, frameParams);
@@ -205,23 +202,23 @@ public class MediaControlView extends FrameLayout /* implements OnLayoutChangeLi
 
 
     private void initControllerView(View v) {
-        mPauseButton = (ImageButton) v.findViewById(R.id.playBtn);
+        mPauseButton = v.findViewById(R.id.playBtn);
         if (mPauseButton != null) {
             mPauseButton.requestFocus();
             mPauseButton.setOnClickListener(this);
         }
 
-        mFfwdButton = (ImageButton) v.findViewById(R.id.forwardBtn);
+        mFfwdButton = v.findViewById(R.id.forwardBtn);
         if (mFfwdButton != null) {
             mFfwdButton.setOnClickListener(this);
         }
 
-        mRewButton = (ImageButton) v.findViewById(R.id.rewindBtn);
+        mRewButton = v.findViewById(R.id.rewindBtn);
         if (mRewButton != null) {
             mRewButton.setOnClickListener(this);
         }
 
-        mProgress = (ProgressBar) v.findViewById(R.id.progressBar);
+        mProgress = v.findViewById(R.id.progressBar);
         if (mProgress != null) {
             if (mProgress instanceof SeekBar) {
                 SeekBar seeker = (SeekBar) mProgress;
@@ -233,11 +230,10 @@ public class MediaControlView extends FrameLayout /* implements OnLayoutChangeLi
             mProgress.setMax(1000);
         }
 
-        mEndTime = (TextView) v.findViewById(R.id.totalTimeText);
-        mCurrentTime = (TextView) v.findViewById(R.id.currentTimeText);
+        mEndTime = v.findViewById(R.id.totalTimeText);
+        mCurrentTime = v.findViewById(R.id.currentTimeText);
     }
 
-
     /**
      * Disable pause or seek buttons if the stream cannot be paused or seeked.
      * This requires the control interface to be a MediaPlayerControlExt

+ 1 - 2
src/main/java/com/owncloud/android/ui/activity/Preferences.java

@@ -109,7 +109,6 @@ public class Preferences extends PreferenceActivity
     private SwitchPreference fPrint;
     private SwitchPreference mShowHiddenFiles;
     private SwitchPreference mExpertMode;
-    private Preference pAboutApp;
     private AppCompatDelegate mDelegate;
 
     private ListPreference mPrefStoragePath;
@@ -208,7 +207,7 @@ public class Preferences extends PreferenceActivity
                 accentColor));
 
         /* About App */
-        pAboutApp = findPreference("about_app");
+        Preference pAboutApp = findPreference("about_app");
         if (pAboutApp != null) {
             pAboutApp.setTitle(String.format(getString(R.string.about_android), getString(R.string.app_name)));
             pAboutApp.setSummary(String.format(getString(R.string.about_version), appVersion));

+ 0 - 2
src/main/java/com/owncloud/android/ui/dialog/SendShareDialog.java

@@ -51,7 +51,6 @@ import java.util.List;
  * You should have received a copy of the GNU Affero General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-
 public class SendShareDialog extends BottomSheetDialogFragment {
 
     private static final String KEY_OCFILE = "KEY_OCFILE";
@@ -62,7 +61,6 @@ public class SendShareDialog extends BottomSheetDialogFragment {
     private View view;
     private OCFile file;
     private FileOperationsHelper fileOperationsHelper;
-    private FileDisplayActivity fileDisplayActivity;
 
     public static SendShareDialog newInstance(OCFile file) {
 

+ 6 - 7
src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java

@@ -1,4 +1,4 @@
-/**
+/*
  *   ownCloud Android client application
  *
  *   @author Bartek Przybylski
@@ -294,19 +294,18 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
         }
 
         item = menu.findItem(R.id.action_send_share_file);
-        ThemeUtils.tintDrawable(item.getIcon(), ThemeUtils.fontColor());
-        item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
+        if (item != null) {
+            ThemeUtils.tintDrawable(item.getIcon(), ThemeUtils.fontColor());
+            item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
+            if (getFile().isSharedWithMe() && !getFile().canReshare()) {
+                // additional restriction for this fragment
 
-        if(getFile().isSharedWithMe() && !getFile().canReshare()){
-            // additional restriction for this fragment
-            if(item != null){
                 item.setVisible(false);
                 item.setEnabled(false);
             }
         }
     }
 
-
     /**
      * {@inheritDoc}
      */

+ 1 - 2
src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java

@@ -68,8 +68,7 @@ public class PreviewImageActivity extends FileActivity implements
         ViewPager.OnPageChangeListener, OnRemoteOperationListener {
 
     public static final String TAG = PreviewImageActivity.class.getSimpleName();
-    
-    public static final String KEY_WAITING_TO_PREVIEW = "WAITING_TO_PREVIEW";
+
     private static final String KEY_WAITING_FOR_BINDER = "WAITING_FOR_BINDER";
     private static final String KEY_SYSTEM_VISIBLE = "TRUE";
 

+ 12 - 14
src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.java

@@ -87,7 +87,6 @@ public class PreviewMediaFragment extends FileFragment implements
     private static final String EXTRA_PLAY_POSITION = "PLAY_POSITION";
     private static final String EXTRA_PLAYING = "PLAYING";
 
-    private View mView;
     private Account mAccount;
     private ImageView mImagePreview;
     private VideoView mVideoPreview;
@@ -105,7 +104,6 @@ public class PreviewMediaFragment extends FileFragment implements
     private MediaServiceBinder mMediaServiceBinder = null;
     private MediaControlView mMediaController = null;
     private MediaServiceConnection mMediaServiceConnection = null;
-    private VideoHelper mVideoHelper;
     private boolean mAutoplay;
     private static boolean mOnResume = false;
     public boolean mPrepared;
@@ -186,19 +184,19 @@ public class PreviewMediaFragment extends FileFragment implements
         Log_OC.v(TAG, "onCreateView");
 
 
-        mView = inflater.inflate(R.layout.file_preview, container, false);
+        View view = inflater.inflate(R.layout.file_preview, container, false);
 
-        mPreviewContainer = mView.findViewById(R.id.file_preview_container);
-        mImagePreview = mView.findViewById(R.id.image_preview);
-        mVideoPreview = mView.findViewById(R.id.video_preview);
+        mPreviewContainer = view.findViewById(R.id.file_preview_container);
+        mImagePreview = view.findViewById(R.id.image_preview);
+        mVideoPreview = view.findViewById(R.id.video_preview);
         mVideoPreview.setOnTouchListener(this);
 
-        mMediaController = mView.findViewById(R.id.media_controller);
-        mMultiView = mView.findViewById(R.id.multi_view);
+        mMediaController = view.findViewById(R.id.media_controller);
+        mMultiView = view.findViewById(R.id.multi_view);
 
-        setupMultiView(mView);
+        setupMultiView(view);
         setMultiListLoadingMessage();
-        return mView;
+        return view;
     }
 
 
@@ -491,10 +489,10 @@ public class PreviewMediaFragment extends FileFragment implements
 
     private void prepareVideo() {
         // create helper to get more control on the playback
-        mVideoHelper = new VideoHelper();
-        mVideoPreview.setOnPreparedListener(mVideoHelper);
-        mVideoPreview.setOnCompletionListener(mVideoHelper);
-        mVideoPreview.setOnErrorListener(mVideoHelper);
+        VideoHelper videoHelper = new VideoHelper();
+        mVideoPreview.setOnPreparedListener(videoHelper);
+        mVideoPreview.setOnCompletionListener(videoHelper);
+        mVideoPreview.setOnErrorListener(videoHelper);
     }
 
     @SuppressWarnings("static-access")

+ 1 - 0
src/test/java/com/owncloud/android/authentication/AuthenticatorDataUrlTest.java

@@ -166,6 +166,7 @@ public class AuthenticatorDataUrlTest {
                 Assert.fail("Illegal Argument Exception expected!");
             } catch (IllegalArgumentException e) {
                 // all well
+                System.out.println("Expected Illegal Argument Exception caught.");
             }
         }
     }