Browse Source

Fix crash due to obsolete string resources

David A. Velasco 9 years ago
parent
commit
301ec578bc

+ 2 - 2
res/values/strings.xml

@@ -454,8 +454,8 @@
 
 
     <string name="permission_storage_access">Additional permissions required to upload &amp; download files.</string>
     <string name="permission_storage_access">Additional permissions required to upload &amp; download files.</string>
     <string name="local_file_not_found_toast">The file was not found in the local file system</string>
     <string name="local_file_not_found_toast">The file was not found in the local file system</string>
-    <string name="confirmation_remove_files_alert">Do you really want to remove selected items?</string>
-    <string name="confirmation_remove_folders_alert">Do you really want to remove a folder and its content?</string>
+    <string name="confirmation_remove_files_alert">Do you really want to remove the selected items?</string>
+    <string name="confirmation_remove_folders_alert">Do you really want to remove the selected items and their contents?</string>
     <string name="confirmation_remove_files">selected items</string>
     <string name="confirmation_remove_files">selected items</string>
 
 
 </resources>
 </resources>

+ 5 - 6
src/com/owncloud/android/ui/dialog/RemoveFileDialogFragment.java

@@ -52,14 +52,13 @@ implements ConfirmationDialogFragmentListener {
         RemoveFileDialogFragment frag = new RemoveFileDialogFragment();
         RemoveFileDialogFragment frag = new RemoveFileDialogFragment();
         Bundle args = new Bundle();
         Bundle args = new Bundle();
         
         
-        int messageStringId = R.string.confirmation_remove_file_alert;
+        int messageStringId = (file.isFolder()) ?
+            R.string.confirmation_remove_folder_alert :
+            R.string.confirmation_remove_file_alert;
         
         
         int localRemoveButton = (!file.isFavorite() && (file.isFolder() || file.isDown())) ?
         int localRemoveButton = (!file.isFavorite() && (file.isFolder() || file.isDown())) ?
-            R.string.confirmation_remove_local : -1;
-
-        if (file.isFolder()) {
-            messageStringId = R.string.confirmation_remove_folder_alert;
-        }
+            R.string.confirmation_remove_local :
+            -1;
 
 
         args.putInt(ARG_MESSAGE_RESOURCE_ID, messageStringId);
         args.putInt(ARG_MESSAGE_RESOURCE_ID, messageStringId);
         args.putStringArray(ARG_MESSAGE_ARGUMENTS, new String[]{file.getFileName()});
         args.putStringArray(ARG_MESSAGE_ARGUMENTS, new String[]{file.getFileName()});

+ 13 - 17
src/com/owncloud/android/ui/dialog/RemoveFilesDialogFragment.java

@@ -50,39 +50,35 @@ implements ConfirmationDialogFragmentListener {
     /**
     /**
      * Public factory method to create new RemoveFileDialogFragment instances.
      * Public factory method to create new RemoveFileDialogFragment instances.
      * 
      * 
-     * @param files            Files to remove.
+     * @param files           Files to remove.
      * @return                Dialog ready to show.
      * @return                Dialog ready to show.
      */
      */
     public static RemoveFilesDialogFragment newInstance(ArrayList<OCFile> files) {
     public static RemoveFilesDialogFragment newInstance(ArrayList<OCFile> files) {
         RemoveFilesDialogFragment frag = new RemoveFilesDialogFragment();
         RemoveFilesDialogFragment frag = new RemoveFilesDialogFragment();
         Bundle args = new Bundle();
         Bundle args = new Bundle();
         
         
-        int messageStringId = R.string.confirmation_remove_files_alert;
-        
-        int posBtn = R.string.confirmation_remove_file_remote;
-        int negBtn = -1;
-
         boolean containsFolder = false;
         boolean containsFolder = false;
         boolean containsDown = false;
         boolean containsDown = false;
+        boolean containsFavorite = false;
         for (OCFile file: files) {
         for (OCFile file: files) {
             if (file.isFolder()) containsFolder = true;
             if (file.isFolder()) containsFolder = true;
             if (file.isDown()) containsDown = true;
             if (file.isDown()) containsDown = true;
+            if (file.isFavorite()) containsFavorite = true;
         }
         }
 
 
-        if (containsFolder) {
-            messageStringId = R.string.confirmation_remove_folders_alert;
-            posBtn = R.string.confirmation_remove_remote_and_local;
-            negBtn = R.string.confirmation_remove_local;
-        } else if (containsDown) {
-            posBtn = R.string.confirmation_remove_remote_and_local;
-            negBtn = R.string.confirmation_remove_local;
-        }
-        
+        int messageStringId = (containsFolder) ?
+            R.string.confirmation_remove_folders_alert :
+            R.string.confirmation_remove_files_alert;
+
+        int localRemoveButton = (!containsFavorite && (containsFolder || containsDown)) ?
+            R.string.confirmation_remove_local :
+            -1;
+
         args.putInt(ARG_MESSAGE_RESOURCE_ID, messageStringId);
         args.putInt(ARG_MESSAGE_RESOURCE_ID, messageStringId);
         args.putStringArray(ARG_MESSAGE_ARGUMENTS, new String[]{MainApp.getAppContext().getString(R.string.confirmation_remove_files)});
         args.putStringArray(ARG_MESSAGE_ARGUMENTS, new String[]{MainApp.getAppContext().getString(R.string.confirmation_remove_files)});
-        args.putInt(ARG_POSITIVE_BTN_RES, posBtn);
+        args.putInt(ARG_POSITIVE_BTN_RES, R.string.common_yes);
         args.putInt(ARG_NEUTRAL_BTN_RES, R.string.common_no);
         args.putInt(ARG_NEUTRAL_BTN_RES, R.string.common_no);
-        args.putInt(ARG_NEGATIVE_BTN_RES, negBtn);
+        args.putInt(ARG_NEGATIVE_BTN_RES, localRemoveButton);
         args.putParcelableArrayList(ARG_TARGET_FILES, files);
         args.putParcelableArrayList(ARG_TARGET_FILES, files);
         frag.setArguments(args);
         frag.setArguments(args);