Переглянути джерело

Merge 5c56014f891559e1cdc69bc1339f8afe4a4ab6c0 into bc80cac6b86f16e3e6af522fc405b8ebdeb05195

Andy Scherzinger 6 роки тому
батько
коміт
9a71255e68

+ 5 - 3
src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java

@@ -346,10 +346,11 @@ public class FileDataStorageManager {
 
         // prepare operations to remove files in the given folder
         String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + AND + ProviderTableMeta.FILE_PATH + "=?";
-        String[] whereArgs;
+        String[] whereArgs = new String[2];
         for (OCFile file : filesToRemove) {
             if (file.getParentId() == folder.getFileId()) {
-                whereArgs = new String[]{account.name, file.getRemotePath()};
+                whereArgs[0] = account.name;
+                whereArgs[1] = file.getRemotePath();
                 if (file.isFolder()) {
                     operations.add(ContentProviderOperation.newDelete(
                             ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_DIR, file.getFileId()))
@@ -1577,9 +1578,10 @@ public class FileDataStorageManager {
             List<OCShare> shares, ArrayList<ContentProviderOperation> operations) {
 
         if (shares != null) {
+            ContentValues cv;
             // prepare operations to insert or update files to save in the given folder
             for (OCShare share : shares) {
-                ContentValues cv = new ContentValues();
+                cv = new ContentValues();
                 cv.put(ProviderTableMeta.OCSHARES_FILE_SOURCE, share.getFileSource());
                 cv.put(ProviderTableMeta.OCSHARES_ITEM_SOURCE, share.getItemSource());
                 cv.put(ProviderTableMeta.OCSHARES_SHARE_TYPE, share.getShareType().getValue());

+ 4 - 5
src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java

@@ -73,7 +73,6 @@ import java.lang.ref.WeakReference;
 import java.net.URLEncoder;
 import java.util.List;
 
-import androidx.annotation.Nullable;
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 
 /**
@@ -551,7 +550,7 @@ public final class ThumbnailsCacheManager {
 
                 if (thumbnail == null) {
                     // check if resized version is available
-                    String resizedImageKey = PREFIX_RESIZED_IMAGE + String.valueOf(file.getRemoteId());
+                    String resizedImageKey = PREFIX_RESIZED_IMAGE + file.getRemoteId();
                     Bitmap resizedImage = getBitmapFromDiskCache(resizedImageKey);
 
                     if (resizedImage != null) {
@@ -665,7 +664,7 @@ public final class ThumbnailsCacheManager {
         private enum Type {IMAGE, VIDEO}
         private final WeakReference<ImageView> mImageViewReference;
         private File mFile;
-        private String mImageKey = null;
+        private String mImageKey;
         private Context mContext;
 
         public MediaThumbnailGenerationTask(ImageView imageView, Context context) {
@@ -1169,7 +1168,7 @@ public final class ThumbnailsCacheManager {
         Point p = getScreenDimension();
         int pxW = p.x;
         int pxH = p.y;
-        String imageKey = PREFIX_RESIZED_IMAGE + String.valueOf(file.getRemoteId());
+        String imageKey = PREFIX_RESIZED_IMAGE + file.getRemoteId();
 
         Bitmap bitmap = BitmapUtils.decodeSampledBitmapFromFile(file.getStoragePath(), pxW, pxH);
 
@@ -1187,7 +1186,7 @@ public final class ThumbnailsCacheManager {
         int pxW;
         int pxH;
         pxW = pxH = getThumbnailDimension();
-        String imageKey = PREFIX_THUMBNAIL + String.valueOf(file.getRemoteId());
+        String imageKey = PREFIX_THUMBNAIL + file.getRemoteId();
 
         GetMethod getMethod = null;
 

+ 2 - 1
src/main/java/com/owncloud/android/jobs/NotificationJob.java

@@ -88,6 +88,7 @@ public class NotificationJob extends Job {
     private static final String KEY_NOTIFICATION_ACTION_TYPE = "KEY_NOTIFICATION_ACTION_TYPE";
     private static final String PUSH_NOTIFICATION_ID = "PUSH_NOTIFICATION_ID";
     private static final String NUMERIC_NOTIFICATION_ID = "NUMERIC_NOTIFICATION_ID";
+    public static final String APP_SPREED = "spreed";
 
     private SecureRandom randomId = new SecureRandom();
     private Context context;
@@ -121,7 +122,7 @@ public class NotificationJob extends Job {
                                                                                   DecryptedPushMessage.class);
 
                         // We ignore Spreed messages for now
-                        if (!"spreed".equals(decryptedPushMessage.getApp())) {
+                        if (!APP_SPREED.equals(decryptedPushMessage.getApp())) {
                             fetchCompleteNotification(signatureVerification.getAccount(), decryptedPushMessage);
                         }
                     }

+ 5 - 7
src/main/java/com/owncloud/android/providers/DocumentsStorageProvider.java

@@ -116,7 +116,6 @@ public class DocumentsStorageProvider extends DocumentsProvider {
         final long docId = Long.parseLong(documentId);
         updateCurrentStorageManagerIfNeeded(docId);
 
-        final FileCursor result = new FileCursor(projection);
         if (currentStorageManager == null) {
 
             for (Map.Entry<Long, FileDataStorageManager> entry : rootIdToStorageManager.entrySet()) {
@@ -131,6 +130,7 @@ public class DocumentsStorageProvider extends DocumentsProvider {
             throw new FileNotFoundException("File with id " + documentId + " not found");
         }
 
+        final FileCursor result = new FileCursor(projection);
         OCFile file = currentStorageManager.getFileById(docId);
         if (file != null) {
             result.addFile(file);
@@ -147,16 +147,14 @@ public class DocumentsStorageProvider extends DocumentsProvider {
         final long folderId = Long.parseLong(parentDocumentId);
         updateCurrentStorageManagerIfNeeded(folderId);
 
-        final OCFile browsedDir = currentStorageManager.getFileById(folderId);
-
-        Account account = currentStorageManager.getAccount();
-
         Context context = getContext();
 
         if (context == null) {
             throw new FileNotFoundException("Context may not be null");
         }
 
+        Account account = currentStorageManager.getAccount();
+        final OCFile browsedDir = currentStorageManager.getFileById(folderId);
         if (Device.getNetworkType(context).equals(JobRequest.NetworkType.UNMETERED)) {
             RemoteOperationResult result = new RefreshFolderOperation(browsedDir, System.currentTimeMillis(), false,
                                                                       false, true, currentStorageManager, account,
@@ -189,13 +187,13 @@ public class DocumentsStorageProvider extends DocumentsProvider {
             throw new FileNotFoundException("File not found: " + documentId);
         }
 
-        Account account = currentStorageManager.getAccount();
         Context context = getContext();
 
         if (context == null) {
             throw new FileNotFoundException("Context may not be null!");
         }
 
+        Account account = currentStorageManager.getAccount();
         if (!ocFile.isDown()) {
             Intent i = new Intent(getContext(), FileDownloader.class);
             i.putExtra(FileDownloader.EXTRA_ACCOUNT, account);
@@ -254,7 +252,7 @@ public class DocumentsStorageProvider extends DocumentsProvider {
 
         File file = new File(ocFile.getStoragePath());
         int accessMode = ParcelFileDescriptor.parseMode(mode);
-        boolean isWrite = (mode.indexOf('w') != -1);
+        boolean isWrite = mode.indexOf('w') != -1;
 
         final OCFile oldFile = ocFile;
         final OCFile newFile = ocFile;

+ 7 - 2
src/main/java/com/owncloud/android/providers/FileContentProvider.java

@@ -875,6 +875,7 @@ public class FileContentProvider extends ContentProvider {
             String username;
             String oldAccountName;
             String newAccountName;
+            String[] accountOwner = new String[1];
 
             for (Account account : accounts) {
                 // build both old and new account name
@@ -888,10 +889,11 @@ public class FileContentProvider extends ContentProvider {
                 try {
                     ContentValues cv = new ContentValues();
                     cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, newAccountName);
+                    accountOwner[0] = oldAccountName;
                     int num = db.update(ProviderTableMeta.FILE_TABLE_NAME,
                                         cv,
                                         ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?",
-                                        new String[]{oldAccountName});
+                                        accountOwner);
 
                     Log_OC.d(SQL, "Updated account in database: old name == " + oldAccountName +
                         ", new name == " + newAccountName + " (" + num + " rows updated )");
@@ -944,6 +946,8 @@ public class FileContentProvider extends ContentProvider {
                 File newAccountFolder = new File(newAccountPath);
                 oldAccountFolder.renameTo(newAccountFolder);
 
+                String[] storagePath = new String[1];
+
                 // update database
                 do {
                     // Update database
@@ -955,10 +959,11 @@ public class FileContentProvider extends ContentProvider {
 
                     ContentValues cv = new ContentValues();
                     cv.put(ProviderTableMeta.FILE_STORAGE_PATH, newPath);
+                    storagePath[0] = oldPath;
                     db.update(ProviderTableMeta.FILE_TABLE_NAME,
                               cv,
                               ProviderTableMeta.FILE_STORAGE_PATH + "=?",
-                              new String[]{oldPath});
+                              storagePath);
 
                     Log_OC.v(SQL, "Updated path of downloaded file: old file name == " + oldPath +
                         ", new file name == " + newPath);

+ 4 - 5
src/main/java/com/owncloud/android/ui/adapter/NotificationListAdapter.java

@@ -74,7 +74,6 @@ import butterknife.ButterKnife;
  * This Adapter populates a RecyclerView with all notifications for an account within the app.
  */
 public class NotificationListAdapter extends RecyclerView.Adapter<NotificationListAdapter.NotificationViewHolder> {
-    private static final String TAG = NotificationListAdapter.class.getSimpleName();
     private StyleSpan styleSpanBold = new StyleSpan(Typeface.BOLD);
     private ForegroundColorSpan foregroundColorSpanBlack = new ForegroundColorSpan(Color.BLACK);
 
@@ -134,7 +133,10 @@ public class NotificationListAdapter extends RecyclerView.Adapter<NotificationLi
 
         Resources resources = notificationsActivity.getResources();
         NotificationExecuteActionTask task = new NotificationExecuteActionTask(client, holder, notificationsActivity);
-
+        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
+            ViewGroup.LayoutParams.WRAP_CONTENT);
+        params.setMargins(20, 0, 20, 0);
+        
         for (Action action : notification.getActions()) {
             button = new MaterialButton(notificationsActivity);
 
@@ -157,9 +159,6 @@ public class NotificationListAdapter extends RecyclerView.Adapter<NotificationLi
             button.setText(action.label);
             button.setCornerRadiusResource(R.dimen.button_corner_radius);
 
-            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
-                                                                             ViewGroup.LayoutParams.WRAP_CONTENT);
-            params.setMargins(20, 0, 20, 0);
             button.setLayoutParams(params);
             button.setGravity(Gravity.CENTER);
 

+ 5 - 6
src/main/java/com/owncloud/android/ui/adapter/OCFileListAdapter.java

@@ -819,13 +819,12 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
             Vector<OCFile> filteredFiles = new Vector<>();
 
             if (!TextUtils.isEmpty(constraint)) {
-                for (int i = 0; i < mFilesAll.size(); i++) {
-                    OCFile currentFile = mFilesAll.get(i);
-                    if (currentFile.getParentRemotePath().equals(currentDirectory.getRemotePath()) &&
-                            currentFile.getFileName().toLowerCase(Locale.getDefault()).contains(
+                for (OCFile file : mFilesAll) {
+                    if (file.getParentRemotePath().equals(currentDirectory.getRemotePath()) &&
+                        file.getFileName().toLowerCase(Locale.getDefault()).contains(
                                     constraint.toString().toLowerCase(Locale.getDefault())) &&
-                            !filteredFiles.contains(currentFile)) {
-                        filteredFiles.add(currentFile);
+                            !filteredFiles.contains(file)) {
+                        filteredFiles.add(file);
                     }
                 }
             }

+ 2 - 2
src/main/java/com/owncloud/android/ui/fragment/EditShareFragment.java

@@ -380,8 +380,8 @@ public class EditShareFragment extends Fragment {
                 }
                 if (canEditCompound.isChecked() && allDisabled) {
                     toggleDisablingListener(canEditCompound);
-                    for (int i = 0; i < sSubordinateCheckBoxIds.length; i++) {
-                        getView().findViewById(sSubordinateCheckBoxIds[i]).setVisibility(View.GONE);
+                    for (int sSubordinateCheckBoxId : sSubordinateCheckBoxIds) {
+                        getView().findViewById(sSubordinateCheckBoxId).setVisibility(View.GONE);
                     }
                 }
             }

+ 1 - 1
src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java

@@ -391,7 +391,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
      * register listener on FAB.
      */
     private void registerFabListener() {
-        FileActivity activity = ((FileActivity) getActivity());
+        FileActivity activity = (FileActivity) getActivity();
         getFabMain().setOnClickListener(v -> {
             new OCFileListBottomSheetDialog(activity, this).show();
         });

+ 1 - 1
src/main/java/com/owncloud/android/ui/trashbin/TrashbinActivity.java

@@ -85,7 +85,7 @@ public class TrashbinActivity extends FileActivity implements TrashbinActivityIn
     private TrashbinListAdapter trashbinListAdapter;
     private TrashbinPresenter trashbinPresenter;
 
-    private boolean active = false;
+    private boolean active;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {

+ 0 - 4
src/main/java/com/owncloud/android/utils/DeviceCredentialUtils.java

@@ -36,10 +36,6 @@ public final class DeviceCredentialUtils {
 
     private static final String TAG = DeviceCredentialUtils.class.getSimpleName();
 
-    private static final int AUTHENTICATION_DURATION_SECONDS = 30;
-
-    private static final String ANDROID_KEY_STORE = "AndroidKeyStore";
-
     private DeviceCredentialUtils() {
         // utility class -> private constructor
     }