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

Added args for SyncFileNotEnoughSpaceFragment (unfinished)

Caption support is missing
Kilian Périsset 5 жил өмнө
parent
commit
9fac55da6b

+ 39 - 20
src/main/java/com/owncloud/android/ui/dialog/SyncFileNotEnoughSpaceDialogFragment.java

@@ -20,6 +20,7 @@
 package com.owncloud.android.ui.dialog;
 
 import android.app.Dialog;
+import android.content.res.Resources;
 import android.os.Bundle;
 import android.view.ActionMode;
 
@@ -44,8 +45,17 @@ import androidx.appcompat.app.AlertDialog;
 public class SyncFileNotEnoughSpaceDialogFragment extends ConfirmationDialogFragment implements
         ConfirmationDialogFragmentListener {
 
-    private ActionMode actionMode;
 
+    private static final String ARG_DIALOG_TITLE = "dialog_title_res";
+    private static final String ARG_DIALOG_MESSAGE = "dialog_message_res";
+    private static final String ARG_FILE_NAME = "dialog_file_name";
+    private static final String ARG_FILE_SIZE = "dialog_file_size";
+    private static final String ARG_DEVICE_FREE_SPACE = "dialog_device_free_space";
+
+    private ActionMode actionMode;
+    String properFileSize;
+    String properDiskFreeSpace;
+    String fileName;
 
     public static SyncFileNotEnoughSpaceDialogFragment newInstance(OCFile file, long availableDeviceSpace,
                                                                    ActionMode actionMode) {
@@ -90,30 +100,31 @@ public class SyncFileNotEnoughSpaceDialogFragment extends ConfirmationDialogFrag
         // </EXPORTED>
         // ------------------
 
-        int messageStringId;
-
-
-        boolean containsFolder = false;
-        boolean containsDown = false;
-
-        int localRemoveButton = (containsFolder || containsDown) ? R.string.confirmation_remove_local : -1;
-
         // Here,
         /*
             - Title : Not enough space
-            - Base message  : {0} is {1} but there is only {2} available on device.
-            - Button top - positive : Choose what to sync.
-            - Button mid - neutral : Free up space
-            - Button bot - negative : Cancel
+            - Base message  : {0} is {1} but there is only {2} available on device. -> applied
+            - Button top - positive : Choose what to synchronize -> applied
+            - Button mid - neutral : Free up space ->
+            - Button bot - negative : Cancel (R.string.common_cancel)
             - {0} : File name (file.getFileName)
             - {1} : File size
             - {2} : Device free space
          */
 
         // args.putInt(ARG_MESSAGE_RESOURCE_ID, messageStringId);
-        args.putInt(ARG_POSITIVE_BTN_RES, R.string.file_delete);
-        args.putInt(ARG_NEUTRAL_BTN_RES, R.string.file_keep);
-        args.putInt(ARG_NEGATIVE_BTN_RES, localRemoveButton);
+
+
+        args.putInt(ARG_DIALOG_TITLE, R.string.sync_not_enough_space_dialog_title);
+        args.putInt(ARG_DIALOG_MESSAGE, R.string.sync_not_enough_space_dialog_placeholder);
+        args.putInt(ARG_POSITIVE_BTN_RES, R.string.sync_not_enough_space_dialog_action_choose);
+        args.putInt(ARG_NEUTRAL_BTN_RES, R.string.sync_not_enough_space_dialog_action_free_space);
+        args.putInt(ARG_NEGATIVE_BTN_RES, R.string.common_cancel);
+
+        args.putString(ARG_FILE_NAME, file.getFileName());
+        args.putLong(ARG_FILE_SIZE, file.getFileLength());
+        args.putLong(ARG_DEVICE_FREE_SPACE, availableDeviceSpace);
+
         frag.setArguments(args);
 
         return frag;
@@ -124,18 +135,26 @@ public class SyncFileNotEnoughSpaceDialogFragment extends ConfirmationDialogFrag
         super.onStart();
 
         int color = ThemeUtils.primaryAccentColor(getActivity());
-
         AlertDialog alertDialog = (AlertDialog) getDialog();
 
-        alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(color);
-        alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(color);
-        alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL).setTextColor(color);
+        if (alertDialog != null) {
+            alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(color);
+            alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(color);
+            alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL).setTextColor(color);
+        }
     }
 
     @NonNull
     @Override
     public Dialog onCreateDialog(Bundle savedInstanceState) {
         Dialog dialog = super.onCreateDialog(savedInstanceState);
+
+        if (getArguments() != null) {
+            properDiskFreeSpace = DisplayUtils.bytesToHumanReadable(getArguments().getLong(ARG_DEVICE_FREE_SPACE));
+            properFileSize = DisplayUtils.bytesToHumanReadable(getArguments().getLong(ARG_FILE_SIZE));
+            fileName = getArguments().getString(ARG_FILE_NAME);
+        }
+
         // mTargetFiles = getArguments().getParcelableArrayList(ARG_TARGET_FILES);
 
         setOnConfirmationListener(this);