Prevent deleting folders with children

pull/217/head
M66B 5 months ago
parent 9496192648
commit 161f96dc05

@ -109,7 +109,7 @@ Related questions:
* Load more messages: long press a folder in the folder list, select *Fetch more messages*
* Delete a message, skipping trash: long press the trash icon
* Delete an account/identity: (Main) Settings, tap Manual setup, tap Accounts/Identities, tap the account/identity, tap the trash icon in the top right corner
* Delete a folder: long press the folder in the folder list, Edit properties, tap the trash icon in the top right corner
* Delete a folder: long press the folder in the folder list, Edit properties, tap the trash icon in the top right corner. Note that you can't delete folders which still have sub folders.
* Undo send: Outbox, swipe the message in the list left or right
* Delete a contact: please [see this FAQ](#faq171)
* Store sent messages in the inbox: please [see this FAQ](#faq142)

@ -730,7 +730,8 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
if (folder.selectable && Shortcuts.can(context))
popupMenu.getMenu().add(Menu.NONE, R.string.title_pin, order++, R.string.title_pin);
if (!folder.read_only && EntityFolder.USER.equals(folder.type))
if (!folder.read_only && EntityFolder.USER.equals(folder.type) &&
(folder.child_refs == null || folder.child_refs.isEmpty()))
popupMenu.getMenu().add(Menu.NONE, R.string.title_delete, order++, R.string.title_delete);
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

@ -52,6 +52,7 @@ import androidx.preference.PreferenceManager;
import com.google.android.material.snackbar.Snackbar;
import java.util.List;
import java.util.Objects;
public class FragmentFolder extends FragmentBase {
@ -301,6 +302,9 @@ public class FragmentFolder extends FragmentBase {
EntityFolder parent = db.folder().getFolderByName(aid, parentName);
EntityFolder folder = db.folder().getFolder(id);
List<EntityFolder> children = db.folder().getChildFolders(id);
args.putBoolean("children", (children != null && !children.isEmpty()));
if (folder != null) {
EntityAccount account = db.account().getAccount(folder.account);
if (account != null) {
@ -377,7 +381,8 @@ public class FragmentFolder extends FragmentBase {
deletable = (folder != null &&
!folder.read_only &&
EntityFolder.USER.equals(folder.type));
EntityFolder.USER.equals(folder.type) &&
!args.getBoolean("children"));
invalidateOptionsMenu();
}

@ -121,7 +121,7 @@
<li>Load more messages: long press a folder in the folder list, select <em>Fetch more messages</em></li>
<li>Delete a message, skipping trash: long press the trash icon</li>
<li>Delete an account/identity: (Main) Settings, tap Manual setup, tap Accounts/Identities, tap the account/identity, tap the trash icon in the top right corner</li>
<li>Delete a folder: long press the folder in the folder list, Edit properties, tap the trash icon in the top right corner</li>
<li>Delete a folder: long press the folder in the folder list, Edit properties, tap the trash icon in the top right corner. Note that you cant delete folders which still have sub folders.</li>
<li>Undo send: Outbox, swipe the message in the list left or right</li>
<li>Delete a contact: please <a href="#faq171">see this FAQ</a></li>
<li>Store sent messages in the inbox: please <a href="#faq142">see this FAQ</a></li>

Loading…
Cancel
Save