Skip to content

Commit

Permalink
Merge pull request #4348 from owncloud/feature/improvements_remove_di…
Browse files Browse the repository at this point in the history
…alog

[FEATURE REQUEST] Improvements in remove confirmation dialog
  • Loading branch information
joragua authored Apr 9, 2024
2 parents cfa8cfe + 696900d commit 47f06ed
Show file tree
Hide file tree
Showing 50 changed files with 181 additions and 49 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ ownCloud admins and users.
* Enhancement - Unit tests for repository classes - Part 1: [#4232](https://github.com/owncloud/android/issues/4232)
* Enhancement - Add a warning in http connections: [#4284](https://github.com/owncloud/android/issues/4284)
* Enhancement - Make dialog more Android-alike: [#4303](https://github.com/owncloud/android/issues/4303)
* Enhancement - Improvements in remove dialog alert: [#4342](https://github.com/owncloud/android/issues/4342)

## Details

Expand Down Expand Up @@ -148,6 +149,15 @@ ownCloud admins and users.
https://github.com/owncloud/android/issues/4303
https://github.com/owncloud/android/pull/4336

* Enhancement - Improvements in remove dialog alert: [#4342](https://github.com/owncloud/android/issues/4342)

A custom dialog alert has been added when the file that is going to be deleted
has thumbnail. Also, when removing files in multiple selection, the number of
elements that are going to be removed is displayed in the dialog.

https://github.com/owncloud/android/issues/4342
https://github.com/owncloud/android/pull/4348

# Changelog for ownCloud Android Client [4.2.1] (2024-02-22)

The following sections list the changes in ownCloud Android Client 4.2.1 relevant to
Expand Down
7 changes: 7 additions & 0 deletions changelog/unreleased/4348
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Enhancement: Improvements in remove dialog alert

A custom dialog alert has been added when the file that is going to be deleted has thumbnail.
Also, when removing files in multiple selection, the number of elements that are going to be removed is displayed in the dialog.

https://github.com/owncloud/android/issues/4342
https://github.com/owncloud/android/pull/4348
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
* @author Jose Antonio Barros Ramos
* @author Juan Carlos Garrote Gascón
* @author Manuel Plazas Palacio
* @author Jorge Aguado Recio
*
* Copyright (C) 2023 ownCloud GmbH.
* Copyright (C) 2024 ownCloud GmbH.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
Expand All @@ -24,6 +25,8 @@
package com.owncloud.android.presentation.files.filelist

import android.annotation.SuppressLint
import android.app.Dialog
import android.content.Context
import android.content.Intent
import android.content.res.ColorStateList
import android.net.Uri
Expand All @@ -35,6 +38,7 @@ import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import android.widget.Button
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
Expand Down Expand Up @@ -475,8 +479,13 @@ class MainFileListFragment : Fragment(),
}

FileMenuOption.REMOVE -> {
filesToRemove = listOf(file)
fileOperationsViewModel.showRemoveDialog(filesToRemove)
if (file.isFolder) {
filesToRemove = listOf(file)
fileOperationsViewModel.showRemoveDialog(filesToRemove)
} else {
showRemoveCustomDialog(file, context)
}

}

FileMenuOption.OPEN_WITH -> {
Expand Down Expand Up @@ -1123,8 +1132,12 @@ class MainFileListFragment : Fragment(),
}

R.id.action_remove_file -> {
filesToRemove = checkedFiles
fileOperationsViewModel.showRemoveDialog(filesToRemove)
if (checkedFiles.size == 1 && !checkedFiles[0].isFolder) {
showRemoveCustomDialog(checkedFiles[0], requireContext())
} else {
filesToRemove = checkedFiles
fileOperationsViewModel.showRemoveDialog(filesToRemove)
}
return true
}

Expand Down Expand Up @@ -1357,6 +1370,52 @@ class MainFileListFragment : Fragment(),
}
}

private fun showRemoveCustomDialog(file: OCFile, context: Context) {
val removeDialog = Dialog(context)
removeDialog.apply {
setContentView(R.layout.remove_files_dialog)
setCancelable(false)
show()
}

val thumbnailImageView = removeDialog.findViewById<ImageView>(R.id.dialog_remove_thumbnail)
val dialogText = removeDialog.findViewById<TextView>(R.id.dialog_remove_information)
val localRemoveButton = removeDialog.findViewById<Button>(R.id.dialog_remove_local_only)
val yesRemoveButton = removeDialog.findViewById<Button>(R.id.dialog_remove_yes)
val noRemoveButton = removeDialog.findViewById<Button>(R.id.dialog_remove_no)

dialogText.text = String.format(getString(R.string.confirmation_remove_file_alert), file.fileName)

// Show the thumbnail when the file has one
val thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(file.remoteId)

if (thumbnail != null) {
thumbnailImageView.setImageBitmap(thumbnail)
} else {
thumbnailImageView.visibility = View.GONE
}

// Hide "Local only" remove button when the file is not available locally
if (!file.isAvailableLocally) {
localRemoveButton.visibility = View.INVISIBLE
}

localRemoveButton.setOnClickListener {
fileOperationsViewModel.performOperation(FileOperation.RemoveOperation(listOf(file), removeOnlyLocalCopy = true))
removeDialog.dismiss()
}

yesRemoveButton.setOnClickListener {
fileOperationsViewModel.performOperation(FileOperation.RemoveOperation(listOf(file), removeOnlyLocalCopy = false))
removeDialog.dismiss()
}

noRemoveButton.setOnClickListener {
// Nothing special to do
removeDialog.dismiss()
}
}

interface FileActions {
fun onCurrentFolderUpdated(newCurrentFolder: OCFile, currentSpace: OCSpace? = null)
fun onFileClicked(file: OCFile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ class RemoveFilesDialogFragment : ConfirmationDialogFragment(), ConfirmationDial
putInt(ARG_MESSAGE_RESOURCE_ID, messageStringId)
if (files.size == 1) {
putStringArray(ARG_MESSAGE_ARGUMENTS, arrayOf(files.first().fileName))
} else {
putStringArray(ARG_MESSAGE_ARGUMENTS, arrayOf(files.size.toString()))
}
putInt(ARG_POSITIVE_BTN_RES, R.string.common_yes)
putInt(ARG_NEUTRAL_BTN_RES, R.string.common_no)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ class ReleaseNotesViewModel(
subtitle = R.string.release_notes_4_3_0_subtitle_clear_data_button_hard_reset,
type = ReleaseNoteType.BUGFIX,
),
ReleaseNote(
title = R.string.release_notes_4_3_0_title_improvements_remove_dialog,
subtitle = R.string.release_notes_4_3_0_subtitle_improvements_remove_dialog,
type = ReleaseNoteType.ENHANCEMENT
)
)
}
}
90 changes: 90 additions & 0 deletions owncloudApp/src/main/res/layout/remove_files_dialog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">

<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/activity_horizontal_margin"
app:cardBackgroundColor="@color/background_color"
app:cardCornerRadius="@dimen/standard_half_margin"
app:cardElevation="0dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginHorizontal="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_horizontal_margin"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_horizontal_margin"
android:orientation="horizontal">

<ImageView
android:id="@+id/dialog_remove_thumbnail"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/standard_margin" />

<TextView
android:id="@+id/dialog_remove_information"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:textColor="@color/black"
android:textSize="@dimen/two_line_primary_text_size"
android:layout_marginStart="@dimen/standard_margin"
android:layout_marginEnd="@dimen/standard_margin"
tools:text="Do you really want to remove this item?" />

</LinearLayout>

<LinearLayout
android:id="@+id/buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="5dp">

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/dialog_remove_no"
style="@style/Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="2"
android:text="@string/common_no" />

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/dialog_remove_local_only"
style="@style/Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/confirmation_remove_local" />

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/dialog_remove_yes"
style="@style/Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="2"
android:text="@string/common_yes" />

</LinearLayout>
</LinearLayout>

</androidx.cardview.widget.CardView>

</LinearLayout>


1 change: 0 additions & 1 deletion owncloudApp/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,6 @@
<string name="action_upload_retry">إعادة المحاولة</string>
<string name="action_upload_clear">مسح</string>
<string name="local_file_not_found_toast">لم يتم العثور على الملف في نظام الملفات المحلية</string>
<string name="confirmation_remove_files_alert">هل ترغب حقًا في إزالة العناصر المحددة؟</string>
<string name="confirmation_remove_folders_alert">هل ترغب حقًا في إزالة العناصر المحددة ومحتوياتها؟</string>
<string name="failed_upload_quota_exceeded_text">لا توجد مساحة كافية في الحساب</string>
<string name="auth_forbidden">مصادقة ممنوعة</string>
Expand Down
1 change: 0 additions & 1 deletion owncloudApp/src/main/res/values-ast/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@
<string name="edit_share_unshare">Dexar de compartir</string>
<string name="edit_share_done">fechu</string>
<string name="local_file_not_found_toast">El ficheru nun s\'atopó nel sistema de ficheros llocal</string>
<string name="confirmation_remove_files_alert">¿De que quies desaniciar los elementos seleicionaos?</string>
<string name="confirmation_remove_folders_alert">¿De xuru que quies desaniciar los elementos seleicionaos y los sos conteníos?</string>
<plurals name="items_selected_count">
<item quantity="one">%d escoyíu</item>
Expand Down
1 change: 0 additions & 1 deletion owncloudApp/src/main/res/values-bg-rBG/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,6 @@
<string name="action_upload_retry">Повторен опит</string>
<string name="action_upload_clear">Изчистване</string>
<string name="local_file_not_found_toast">Файлът не беше намерен в локалната файлова система</string>
<string name="confirmation_remove_files_alert">Наистина ли желаете да премахнете избраните обекти?</string>
<string name="confirmation_remove_folders_alert">Наистина ли желаете да премахнете избраните обекти и тяхното съдържание?</string>
<string name="failed_upload_quota_exceeded_text">Няма достатъчно място в профила</string>
<string name="auth_forbidden">Забранено удостоверяване</string>
Expand Down
1 change: 0 additions & 1 deletion owncloudApp/src/main/res/values-ca/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,6 @@
<string name="action_upload_retry">Torna-ho a intentar</string>
<string name="action_upload_clear">Neteja</string>
<string name="local_file_not_found_toast">El fitxer no s\'ha trobat entre els fitxers locals</string>
<string name="confirmation_remove_files_alert">Segur que vols esborrar els elements seleccionats?</string>
<string name="confirmation_remove_folders_alert">Segur que voleu esborrar els elements seleccionats i els seus continguts?</string>
<string name="failed_upload_quota_exceeded_text">No hi ha prou espai en el compte</string>
<string name="auth_forbidden">Autentificació no autoritzada</string>
Expand Down
1 change: 0 additions & 1 deletion owncloudApp/src/main/res/values-cs-rCZ/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,6 @@ správce systému.</string>
<string name="action_upload_retry">Zkusit znovu</string>
<string name="action_upload_clear">Vyčistit</string>
<string name="local_file_not_found_toast">Soubor nebyl nalezen v místním souborovém systému</string>
<string name="confirmation_remove_files_alert">Opravdu chcete odstranit vybrané položky?</string>
<string name="confirmation_remove_folders_alert">Opravdu chcete odstranit vybrané položky a jejich obsah?</string>
<string name="failed_upload_quota_exceeded_text">Na účtu není dostatek místa</string>
<string name="auth_forbidden">Zakázaná autentizace</string>
Expand Down
1 change: 0 additions & 1 deletion owncloudApp/src/main/res/values-da/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,6 @@
<string name="action_upload_retry">Forsøg igen</string>
<string name="action_upload_clear">Ryd</string>
<string name="local_file_not_found_toast">Filen blev ikke fundet i det lokale filsystem</string>
<string name="confirmation_remove_files_alert">Ønsker du virkelig at fjerne de valgte enheder?</string>
<string name="confirmation_remove_folders_alert">Ønsker du virkelig at fjerne de valgte emner og deres indhold?</string>
<string name="failed_upload_quota_exceeded_text">Ikke nok plads for denne konto</string>
<string name="auth_forbidden">Godkendelse forbudt</string>
Expand Down
1 change: 0 additions & 1 deletion owncloudApp/src/main/res/values-de-rCH/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,6 @@
<string name="action_upload_retry">Wiederholen</string>
<string name="action_upload_clear">Leeren</string>
<string name="local_file_not_found_toast">Die Datei wurde im lokalen Dateisystem nicht gefunden</string>
<string name="confirmation_remove_files_alert">Möchtest du die ausgewählten Elemente wirklich löschen?</string>
<string name="confirmation_remove_folders_alert">Möchtest du die ausgewählten Elemente und dessen Inhalt wirklich löschen?</string>
<string name="failed_upload_quota_exceeded_text">Nicht genügend Speicherplatz im Konto verfügbar</string>
<string name="auth_forbidden">Authentifizierung verweigert</string>
Expand Down
1 change: 0 additions & 1 deletion owncloudApp/src/main/res/values-de-rDE/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,6 @@
<string name="action_upload_retry">Wiederholen</string>
<string name="action_upload_clear">Leeren</string>
<string name="local_file_not_found_toast">Die Datei wurde im lokalen Dateisystem nicht gefunden.</string>
<string name="confirmation_remove_files_alert">Möchten Sie die ausgewählten Elemente wirklich löschen?</string>
<string name="confirmation_remove_folders_alert">Möchten Sie die ausgewählten Elemente und deren Inhalte wirklich löschen?</string>
<string name="failed_upload_quota_exceeded_text">Nicht genügend Speicherplatz im Konto verfügbar</string>
<string name="auth_forbidden">Authentifizierung verweigert</string>
Expand Down
1 change: 0 additions & 1 deletion owncloudApp/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,6 @@
<string name="action_upload_retry">Retry</string>
<string name="action_upload_clear">Leeren</string>
<string name="local_file_not_found_toast">Die Datei wurde im lokalen Dateisystem nicht gefunden</string>
<string name="confirmation_remove_files_alert">Möchtest du die ausgewählten Elemente wirklich löschen?</string>
<string name="confirmation_remove_folders_alert">Möchtest du die ausgewählten Elemente und dessen Inhalt wirklich löschen?</string>
<string name="failed_upload_quota_exceeded_text">Nicht genügend Speicherplatz im Konto verfügbar</string>
<string name="auth_forbidden">Authentifizierung verweigert</string>
Expand Down
1 change: 0 additions & 1 deletion owncloudApp/src/main/res/values-el/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,6 @@
<string name="action_upload_retry">Επανάληψη</string>
<string name="action_upload_clear">Εκκαθάριση</string>
<string name="local_file_not_found_toast">Το αρχείο δεν βρέθηκε στο τοπικό σύστημα αρχείων</string>
<string name="confirmation_remove_files_alert">Θέλετε να διαγράψετε τα επιλεγμένα αντικείμενα;</string>
<string name="confirmation_remove_folders_alert">Θέλετε να διαγράψετε τα επιλεγμένα αντικείμενα και τα περιεχόμενά τους;</string>
<string name="failed_upload_quota_exceeded_text">Δεν υπάρχει αρκετός διαθέσιμος χώρος στον λογαριασμό</string>
<string name="auth_forbidden">Απαγορευμένη πιστοποίηση</string>
Expand Down
1 change: 0 additions & 1 deletion owncloudApp/src/main/res/values-en-rGB/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,6 @@
<string name="action_upload_retry">Retry</string>
<string name="action_upload_clear">Clear</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 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="failed_upload_quota_exceeded_text">Not enough space in the account</string>
<string name="auth_forbidden">Forbidden authentication</string>
Expand Down
1 change: 0 additions & 1 deletion owncloudApp/src/main/res/values-es-rAR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,6 @@
<string name="action_upload_retry">Reintentar</string>
<string name="action_upload_clear">Borrar</string>
<string name="local_file_not_found_toast">El archivo no ha sido encontrado en el sistema local de archivos.</string>
<string name="confirmation_remove_files_alert">¿Realmente quieres eliminar los items seleccionados?</string>
<string name="confirmation_remove_folders_alert">¿Realmente quieres eliminar los ítems seleccionados y su contenido?</string>
<string name="failed_upload_quota_exceeded_text">No hay suficiente espacio en la cuenta</string>
<string name="auth_forbidden">Verificación prohibida</string>
Expand Down
1 change: 0 additions & 1 deletion owncloudApp/src/main/res/values-es-rMX/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,6 @@
<string name="action_upload_retry">Intentar de nuevo</string>
<string name="action_upload_clear">Borrar</string>
<string name="local_file_not_found_toast">El archivo no se encuentra en el servidor local de archivos.</string>
<string name="confirmation_remove_files_alert">¿Realmente deseas eliminar los elementos seleccionados?</string>
<string name="confirmation_remove_folders_alert">¿Realmente deseas eliminar los elementos seleccionados y su contenido?</string>
<string name="failed_upload_quota_exceeded_text">No hay suficiente espacio en la cuenta</string>
<string name="auth_forbidden">Autenticación prohibida</string>
Expand Down
Loading

0 comments on commit 47f06ed

Please sign in to comment.