Skip to content

Commit 47f06ed

Browse files
authored
Merge pull request #4348 from owncloud/feature/improvements_remove_dialog
[FEATURE REQUEST] Improvements in remove confirmation dialog
2 parents cfa8cfe + 696900d commit 47f06ed

File tree

50 files changed

+181
-49
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+181
-49
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ ownCloud admins and users.
4242
* Enhancement - Unit tests for repository classes - Part 1: [#4232](https://github.com/owncloud/android/issues/4232)
4343
* Enhancement - Add a warning in http connections: [#4284](https://github.com/owncloud/android/issues/4284)
4444
* Enhancement - Make dialog more Android-alike: [#4303](https://github.com/owncloud/android/issues/4303)
45+
* Enhancement - Improvements in remove dialog alert: [#4342](https://github.com/owncloud/android/issues/4342)
4546

4647
## Details
4748

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

152+
* Enhancement - Improvements in remove dialog alert: [#4342](https://github.com/owncloud/android/issues/4342)
153+
154+
A custom dialog alert has been added when the file that is going to be deleted
155+
has thumbnail. Also, when removing files in multiple selection, the number of
156+
elements that are going to be removed is displayed in the dialog.
157+
158+
https://github.com/owncloud/android/issues/4342
159+
https://github.com/owncloud/android/pull/4348
160+
151161
# Changelog for ownCloud Android Client [4.2.1] (2024-02-22)
152162

153163
The following sections list the changes in ownCloud Android Client 4.2.1 relevant to

changelog/unreleased/4348

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Enhancement: Improvements in remove dialog alert
2+
3+
A custom dialog alert has been added when the file that is going to be deleted has thumbnail.
4+
Also, when removing files in multiple selection, the number of elements that are going to be removed is displayed in the dialog.
5+
6+
https://github.com/owncloud/android/issues/4342
7+
https://github.com/owncloud/android/pull/4348

owncloudApp/src/main/java/com/owncloud/android/presentation/files/filelist/MainFileListFragment.kt

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
* @author Jose Antonio Barros Ramos
66
* @author Juan Carlos Garrote Gascón
77
* @author Manuel Plazas Palacio
8+
* @author Jorge Aguado Recio
89
*
9-
* Copyright (C) 2023 ownCloud GmbH.
10+
* Copyright (C) 2024 ownCloud GmbH.
1011
*
1112
* This program is free software: you can redistribute it and/or modify
1213
* it under the terms of the GNU General Public License version 2,
@@ -24,6 +25,8 @@
2425
package com.owncloud.android.presentation.files.filelist
2526

2627
import android.annotation.SuppressLint
28+
import android.app.Dialog
29+
import android.content.Context
2730
import android.content.Intent
2831
import android.content.res.ColorStateList
2932
import android.net.Uri
@@ -35,6 +38,7 @@ import android.view.MenuItem
3538
import android.view.View
3639
import android.view.ViewGroup
3740
import android.view.WindowManager
41+
import android.widget.Button
3842
import android.widget.ImageView
3943
import android.widget.LinearLayout
4044
import android.widget.TextView
@@ -475,8 +479,13 @@ class MainFileListFragment : Fragment(),
475479
}
476480

477481
FileMenuOption.REMOVE -> {
478-
filesToRemove = listOf(file)
479-
fileOperationsViewModel.showRemoveDialog(filesToRemove)
482+
if (file.isFolder) {
483+
filesToRemove = listOf(file)
484+
fileOperationsViewModel.showRemoveDialog(filesToRemove)
485+
} else {
486+
showRemoveCustomDialog(file, context)
487+
}
488+
480489
}
481490

482491
FileMenuOption.OPEN_WITH -> {
@@ -1123,8 +1132,12 @@ class MainFileListFragment : Fragment(),
11231132
}
11241133

11251134
R.id.action_remove_file -> {
1126-
filesToRemove = checkedFiles
1127-
fileOperationsViewModel.showRemoveDialog(filesToRemove)
1135+
if (checkedFiles.size == 1 && !checkedFiles[0].isFolder) {
1136+
showRemoveCustomDialog(checkedFiles[0], requireContext())
1137+
} else {
1138+
filesToRemove = checkedFiles
1139+
fileOperationsViewModel.showRemoveDialog(filesToRemove)
1140+
}
11281141
return true
11291142
}
11301143

@@ -1357,6 +1370,52 @@ class MainFileListFragment : Fragment(),
13571370
}
13581371
}
13591372

1373+
private fun showRemoveCustomDialog(file: OCFile, context: Context) {
1374+
val removeDialog = Dialog(context)
1375+
removeDialog.apply {
1376+
setContentView(R.layout.remove_files_dialog)
1377+
setCancelable(false)
1378+
show()
1379+
}
1380+
1381+
val thumbnailImageView = removeDialog.findViewById<ImageView>(R.id.dialog_remove_thumbnail)
1382+
val dialogText = removeDialog.findViewById<TextView>(R.id.dialog_remove_information)
1383+
val localRemoveButton = removeDialog.findViewById<Button>(R.id.dialog_remove_local_only)
1384+
val yesRemoveButton = removeDialog.findViewById<Button>(R.id.dialog_remove_yes)
1385+
val noRemoveButton = removeDialog.findViewById<Button>(R.id.dialog_remove_no)
1386+
1387+
dialogText.text = String.format(getString(R.string.confirmation_remove_file_alert), file.fileName)
1388+
1389+
// Show the thumbnail when the file has one
1390+
val thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(file.remoteId)
1391+
1392+
if (thumbnail != null) {
1393+
thumbnailImageView.setImageBitmap(thumbnail)
1394+
} else {
1395+
thumbnailImageView.visibility = View.GONE
1396+
}
1397+
1398+
// Hide "Local only" remove button when the file is not available locally
1399+
if (!file.isAvailableLocally) {
1400+
localRemoveButton.visibility = View.INVISIBLE
1401+
}
1402+
1403+
localRemoveButton.setOnClickListener {
1404+
fileOperationsViewModel.performOperation(FileOperation.RemoveOperation(listOf(file), removeOnlyLocalCopy = true))
1405+
removeDialog.dismiss()
1406+
}
1407+
1408+
yesRemoveButton.setOnClickListener {
1409+
fileOperationsViewModel.performOperation(FileOperation.RemoveOperation(listOf(file), removeOnlyLocalCopy = false))
1410+
removeDialog.dismiss()
1411+
}
1412+
1413+
noRemoveButton.setOnClickListener {
1414+
// Nothing special to do
1415+
removeDialog.dismiss()
1416+
}
1417+
}
1418+
13601419
interface FileActions {
13611420
fun onCurrentFolderUpdated(newCurrentFolder: OCFile, currentSpace: OCSpace? = null)
13621421
fun onFileClicked(file: OCFile)

owncloudApp/src/main/java/com/owncloud/android/presentation/files/removefile/RemoveFilesDialogFragment.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ class RemoveFilesDialogFragment : ConfirmationDialogFragment(), ConfirmationDial
116116
putInt(ARG_MESSAGE_RESOURCE_ID, messageStringId)
117117
if (files.size == 1) {
118118
putStringArray(ARG_MESSAGE_ARGUMENTS, arrayOf(files.first().fileName))
119+
} else {
120+
putStringArray(ARG_MESSAGE_ARGUMENTS, arrayOf(files.size.toString()))
119121
}
120122
putInt(ARG_POSITIVE_BTN_RES, R.string.common_yes)
121123
putInt(ARG_NEUTRAL_BTN_RES, R.string.common_no)

owncloudApp/src/main/java/com/owncloud/android/presentation/releasenotes/ReleaseNotesViewModel.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ class ReleaseNotesViewModel(
9595
subtitle = R.string.release_notes_4_3_0_subtitle_clear_data_button_hard_reset,
9696
type = ReleaseNoteType.BUGFIX,
9797
),
98+
ReleaseNote(
99+
title = R.string.release_notes_4_3_0_title_improvements_remove_dialog,
100+
subtitle = R.string.release_notes_4_3_0_subtitle_improvements_remove_dialog,
101+
type = ReleaseNoteType.ENHANCEMENT
102+
)
98103
)
99104
}
100105
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:app="http://schemas.android.com/apk/res-auto"
5+
xmlns:tools="http://schemas.android.com/tools"
6+
android:layout_width="wrap_content"
7+
android:layout_height="wrap_content"
8+
android:layout_gravity="center">
9+
10+
<androidx.cardview.widget.CardView
11+
android:layout_width="match_parent"
12+
android:layout_height="match_parent"
13+
android:padding="@dimen/activity_horizontal_margin"
14+
app:cardBackgroundColor="@color/background_color"
15+
app:cardCornerRadius="@dimen/standard_half_margin"
16+
app:cardElevation="0dp">
17+
18+
<LinearLayout
19+
android:layout_width="match_parent"
20+
android:layout_height="match_parent"
21+
android:layout_marginHorizontal="@dimen/activity_horizontal_margin"
22+
android:layout_marginTop="@dimen/activity_horizontal_margin"
23+
android:orientation="vertical">
24+
25+
<LinearLayout
26+
android:layout_width="match_parent"
27+
android:layout_height="wrap_content"
28+
android:layout_marginBottom="@dimen/activity_horizontal_margin"
29+
android:orientation="horizontal">
30+
31+
<ImageView
32+
android:id="@+id/dialog_remove_thumbnail"
33+
android:layout_width="50dp"
34+
android:layout_height="50dp"
35+
android:layout_gravity="center_vertical"
36+
android:layout_marginStart="@dimen/standard_margin" />
37+
38+
<TextView
39+
android:id="@+id/dialog_remove_information"
40+
android:layout_width="0dp"
41+
android:layout_height="wrap_content"
42+
android:layout_weight="1"
43+
android:layout_gravity="center_vertical"
44+
android:textColor="@color/black"
45+
android:textSize="@dimen/two_line_primary_text_size"
46+
android:layout_marginStart="@dimen/standard_margin"
47+
android:layout_marginEnd="@dimen/standard_margin"
48+
tools:text="Do you really want to remove this item?" />
49+
50+
</LinearLayout>
51+
52+
<LinearLayout
53+
android:id="@+id/buttons"
54+
android:layout_width="match_parent"
55+
android:layout_height="wrap_content"
56+
android:orientation="horizontal"
57+
android:layout_marginBottom="5dp">
58+
59+
<androidx.appcompat.widget.AppCompatButton
60+
android:id="@+id/dialog_remove_no"
61+
style="@style/Button.Borderless"
62+
android:layout_width="wrap_content"
63+
android:layout_height="match_parent"
64+
android:layout_weight="2"
65+
android:text="@string/common_no" />
66+
67+
<androidx.appcompat.widget.AppCompatButton
68+
android:id="@+id/dialog_remove_local_only"
69+
style="@style/Button.Borderless"
70+
android:layout_width="wrap_content"
71+
android:layout_height="match_parent"
72+
android:layout_weight="1"
73+
android:text="@string/confirmation_remove_local" />
74+
75+
<androidx.appcompat.widget.AppCompatButton
76+
android:id="@+id/dialog_remove_yes"
77+
style="@style/Button.Borderless"
78+
android:layout_width="wrap_content"
79+
android:layout_height="match_parent"
80+
android:layout_weight="2"
81+
android:text="@string/common_yes" />
82+
83+
</LinearLayout>
84+
</LinearLayout>
85+
86+
</androidx.cardview.widget.CardView>
87+
88+
</LinearLayout>
89+
90+

owncloudApp/src/main/res/values-ar/strings.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,6 @@
483483
<string name="action_upload_retry">إعادة المحاولة</string>
484484
<string name="action_upload_clear">مسح</string>
485485
<string name="local_file_not_found_toast">لم يتم العثور على الملف في نظام الملفات المحلية</string>
486-
<string name="confirmation_remove_files_alert">هل ترغب حقًا في إزالة العناصر المحددة؟</string>
487486
<string name="confirmation_remove_folders_alert">هل ترغب حقًا في إزالة العناصر المحددة ومحتوياتها؟</string>
488487
<string name="failed_upload_quota_exceeded_text">لا توجد مساحة كافية في الحساب</string>
489488
<string name="auth_forbidden">مصادقة ممنوعة</string>

owncloudApp/src/main/res/values-ast/strings.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,6 @@
354354
<string name="edit_share_unshare">Dexar de compartir</string>
355355
<string name="edit_share_done">fechu</string>
356356
<string name="local_file_not_found_toast">El ficheru nun s\'atopó nel sistema de ficheros llocal</string>
357-
<string name="confirmation_remove_files_alert">¿De que quies desaniciar los elementos seleicionaos?</string>
358357
<string name="confirmation_remove_folders_alert">¿De xuru que quies desaniciar los elementos seleicionaos y los sos conteníos?</string>
359358
<plurals name="items_selected_count">
360359
<item quantity="one">%d escoyíu</item>

owncloudApp/src/main/res/values-bg-rBG/strings.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,6 @@
470470
<string name="action_upload_retry">Повторен опит</string>
471471
<string name="action_upload_clear">Изчистване</string>
472472
<string name="local_file_not_found_toast">Файлът не беше намерен в локалната файлова система</string>
473-
<string name="confirmation_remove_files_alert">Наистина ли желаете да премахнете избраните обекти?</string>
474473
<string name="confirmation_remove_folders_alert">Наистина ли желаете да премахнете избраните обекти и тяхното съдържание?</string>
475474
<string name="failed_upload_quota_exceeded_text">Няма достатъчно място в профила</string>
476475
<string name="auth_forbidden">Забранено удостоверяване</string>

owncloudApp/src/main/res/values-ca/strings.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,6 @@
466466
<string name="action_upload_retry">Torna-ho a intentar</string>
467467
<string name="action_upload_clear">Neteja</string>
468468
<string name="local_file_not_found_toast">El fitxer no s\'ha trobat entre els fitxers locals</string>
469-
<string name="confirmation_remove_files_alert">Segur que vols esborrar els elements seleccionats?</string>
470469
<string name="confirmation_remove_folders_alert">Segur que voleu esborrar els elements seleccionats i els seus continguts?</string>
471470
<string name="failed_upload_quota_exceeded_text">No hi ha prou espai en el compte</string>
472471
<string name="auth_forbidden">Autentificació no autoritzada</string>

0 commit comments

Comments
 (0)