|
|
|
@ -39,9 +39,13 @@ import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
import com.google.android.material.snackbar.Snackbar;
|
|
|
|
|
|
|
|
|
|
import java.text.Collator;
|
|
|
|
|
import java.text.NumberFormat;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.Comparator;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Locale;
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
import androidx.appcompat.widget.PopupMenu;
|
|
|
|
@ -472,14 +476,45 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|
|
|
|
set(account, show, all);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void set(long account, boolean showAll, @NonNull List<TupleFolderEx> _folders) {
|
|
|
|
|
Log.i("Set account=" + account + " folders=" + _folders.size());
|
|
|
|
|
public void set(final long account, boolean showAll, @NonNull List<TupleFolderEx> folders) {
|
|
|
|
|
Log.i("Set account=" + account + " folders=" + folders.size());
|
|
|
|
|
|
|
|
|
|
this.account = account;
|
|
|
|
|
|
|
|
|
|
List<EntityFolder> folders = new ArrayList<>();
|
|
|
|
|
folders.addAll(_folders);
|
|
|
|
|
EntityFolder.sort(context, folders, false);
|
|
|
|
|
final Collator collator = Collator.getInstance(Locale.getDefault());
|
|
|
|
|
collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc
|
|
|
|
|
|
|
|
|
|
Collections.sort(folders, new Comparator<TupleFolderEx>() {
|
|
|
|
|
@Override
|
|
|
|
|
public int compare(TupleFolderEx f1, TupleFolderEx f2) {
|
|
|
|
|
if (account < 0) {
|
|
|
|
|
String name1 = f1.getDisplayName(context);
|
|
|
|
|
String name2 = f2.getDisplayName(context);
|
|
|
|
|
int n = collator.compare(name1, name2);
|
|
|
|
|
if (n != 0)
|
|
|
|
|
return n;
|
|
|
|
|
|
|
|
|
|
if (f1.accountName == null || f2.accountName == null)
|
|
|
|
|
return 0;
|
|
|
|
|
return f1.accountName.compareTo(f2.accountName);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
int i1 = EntityFolder.FOLDER_SORT_ORDER.indexOf(f1.type);
|
|
|
|
|
int i2 = EntityFolder.FOLDER_SORT_ORDER.indexOf(f2.type);
|
|
|
|
|
int s = Integer.compare(i1, i2);
|
|
|
|
|
if (s != 0)
|
|
|
|
|
return s;
|
|
|
|
|
|
|
|
|
|
int c = -f1.synchronize.compareTo(f2.synchronize);
|
|
|
|
|
if (c != 0)
|
|
|
|
|
return c;
|
|
|
|
|
|
|
|
|
|
String name1 = f1.getDisplayName(context);
|
|
|
|
|
String name2 = f2.getDisplayName(context);
|
|
|
|
|
return collator.compare(name1, name2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
all.clear();
|
|
|
|
|
for (EntityFolder folder : folders)
|
|
|
|
|