Skip to content

Commit

Permalink
Upload file behaviour customized.
Browse files Browse the repository at this point in the history
  • Loading branch information
surinder-tsys committed Aug 5, 2024
1 parent cf222d4 commit b5ca05d
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,8 @@ public void setAutoUploadInit(boolean autoUploadInit) {

@Override
public int getUploaderBehaviour() {
return preferences.getInt(AUTO_PREF__UPLOADER_BEHAVIOR, 1);
//NMC Customization
return preferences.getInt(AUTO_PREF__UPLOADER_BEHAVIOR, 0);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,9 @@ public void onCreate(Bundle savedInstanceState) {

// file upload spinner
List<String> behaviours = new ArrayList<>();
behaviours.add(getString(R.string.uploader_upload_files_behaviour_move_to_nextcloud_folder,
themeUtils.getDefaultDisplayNameForRootFolder(this)));
// Not required this option for NMC
// behaviours.add(getString(R.string.uploader_upload_files_behaviour_move_to_nextcloud_folder,
// themeUtils.getDefaultDisplayNameForRootFolder(this)));
behaviours.add(getString(R.string.uploader_upload_files_behaviour_only_upload));
behaviours.add(getString(R.string.uploader_upload_files_behaviour_upload_and_delete_from_source));

Expand All @@ -207,6 +208,19 @@ public void onCreate(Bundle savedInstanceState) {
behaviourAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
binding.uploadFilesSpinnerBehaviour.setAdapter(behaviourAdapter);
binding.uploadFilesSpinnerBehaviour.setSelection(localBehaviour);
//NMC Customization
binding.uploadFilesSpinnerBehaviour.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
// store behaviour
preferences.setUploaderBehaviour(binding.uploadFilesSpinnerBehaviour.getSelectedItemPosition());
}

@Override
public void onNothingSelected(AdapterView<?> adapterView) {

}
});

// setup the toolbar
setupToolbar();
Expand Down Expand Up @@ -271,7 +285,12 @@ public void showToolbarSpinner() {
private void fillDirectoryDropdown() {
File currentDir = mCurrentDir;
while (currentDir != null && currentDir.getParentFile() != null) {
mDirectories.add(currentDir.getName());
//NMC Customization
if (currentDir.getName().equals("0")) {
mDirectories.add(getResources().getString(R.string.storage_internal_storage));
} else {
mDirectories.add(currentDir.getName());
}
currentDir = currentDir.getParentFile();
}
mDirectories.add(File.separator);
Expand Down Expand Up @@ -502,15 +521,16 @@ public void onCheckAvailableSpaceFinish(boolean hasEnoughSpaceAvailable, String.

// set result code
switch (binding.uploadFilesSpinnerBehaviour.getSelectedItemPosition()) {
case 0: // move to nextcloud folder
// Not required for NMC
/*case 0: // move to nextcloud folder
setResult(RESULT_OK_AND_MOVE, data);
break;
break;*/

case 1: // only upload
case 0: // only upload
setResult(RESULT_OK_AND_DO_NOTHING, data);
break;

case 2: // upload and delete from source
case 1: // upload and delete from source
setResult(RESULT_OK_AND_DELETE, data);
break;

Expand Down Expand Up @@ -576,7 +596,8 @@ private void checkWritableFolder(File folder) {
int localBehaviour = preferences.getUploaderBehaviour();
binding.uploadFilesSpinnerBehaviour.setSelection(localBehaviour);
} else {
binding.uploadFilesSpinnerBehaviour.setSelection(1);
//NMC Customization
binding.uploadFilesSpinnerBehaviour.setSelection(0);
textView.setText(new StringBuilder().append(getString(R.string.uploader_upload_files_behaviour))
.append(' ')
.append(getString(R.string.uploader_upload_files_behaviour_not_writable))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,14 @@ class LocalStoragePathPickerDialogFragment :
Environment.getExternalStoragePublicDirectory(standardDirectory.name).absolutePath
)
}
val sdCard = getString(R.string.storage_internal_storage)
for (dir in FileStorageUtils.getStorageDirectories(requireActivity())) {
//NMC Customisation
if (internalStoragePaths.contains(dir)) {
addIfExists(storagePathItems, R.drawable.ic_sd_grey600, sdCard, dir)
val internalStorage = getString(R.string.storage_internal_storage)
addIfExists(storagePathItems, R.drawable.ic_sd_grey600, internalStorage, dir)
} else {
addIfExists(storagePathItems, R.drawable.ic_sd_grey600, File(dir).name, dir)
val sdCard = getString(R.string.storage_sd_card)
addIfExists(storagePathItems, R.drawable.ic_sd, sdCard, dir)
}
}
return storagePathItems
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,7 @@
<string name="write_email">E-Mail senden</string>
<string name="wrong_storage_path">Speicherordner existiert nicht!</string>
<string name="wrong_storage_path_desc">Ursache könnte die Wiederherstellung einer Sicherungskopie auf einem anderen Gerät sein. Der Standard-Ordner wird jetzt wieder verwendet. Bitte überprüfen Sie die Einstellungen bezüglich des Speicherortes.</string>
<string name="storage_sd_card">SD-Karte</string>
<plurals name="sync_fail_in_favourites_content">
<item quantity="one">Inhalte von %1$d Datei konnten nicht synchronisiert werden (Konflikte: %2$d)</item>
<item quantity="other">Inhalte von %1$d Dateien konnten nicht synchronisiert werden (Konflikte: %2$d)</item>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,7 @@
<string name="delete_link">Delete Link</string>
<string name="share_settings">Settings</string>
<string name="common_confirm">Confirm</string>
<string name="storage_sd_card">SD Card</string>
<string name="strict_mode">Strict mode: no HTTP connection allowed!</string>
<string name="destination_filename">Destination filename</string>
<string name="suggest">Suggest</string>
Expand Down

0 comments on commit b5ca05d

Please sign in to comment.