|
|
|
@ -22,6 +22,7 @@ package eu.faircode.email;
|
|
|
|
|
import android.app.Dialog;
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.content.SharedPreferences;
|
|
|
|
|
import android.graphics.Paint;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.text.Editable;
|
|
|
|
|
import android.text.TextWatcher;
|
|
|
|
@ -77,9 +78,12 @@ public class FragmentDialogFolder extends FragmentDialogBase {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final View dview = LayoutInflater.from(context).inflate(R.layout.dialog_folder_select, null);
|
|
|
|
|
final TextView tvNoFolder = dview.findViewById(R.id.tvNoFolder);
|
|
|
|
|
final AutoCompleteTextView etSearch = dview.findViewById(R.id.etSearch);
|
|
|
|
|
final ImageButton ibNext = dview.findViewById(R.id.ibNext);
|
|
|
|
|
final TextView tvNoFolder = dview.findViewById(R.id.tvNoFolder);
|
|
|
|
|
final TextView tvFavorite1 = dview.findViewById(R.id.tvFavorite1);
|
|
|
|
|
final TextView tvFavorite2 = dview.findViewById(R.id.tvFavorite2);
|
|
|
|
|
final TextView tvFavorite3 = dview.findViewById(R.id.tvFavorite3);
|
|
|
|
|
final RecyclerView rvFolder = dview.findViewById(R.id.rvFolder);
|
|
|
|
|
final ContentLoadingProgressBar pbWait = dview.findViewById(R.id.pbWait);
|
|
|
|
|
final Group grpReady = dview.findViewById(R.id.grpReady);
|
|
|
|
@ -123,7 +127,7 @@ public class FragmentDialogFolder extends FragmentDialogBase {
|
|
|
|
|
final AdapterFolder adapter = new AdapterFolder(context, getViewLifecycleOwner(),
|
|
|
|
|
account, false, false, false, false, new AdapterFolder.IFolderSelectedListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onFolderSelected(TupleFolderEx folder) {
|
|
|
|
|
public void onFolderSelected(@NonNull TupleFolderEx folder) {
|
|
|
|
|
String name = folder.getDisplayName(context, folder.parent_ref);
|
|
|
|
|
selected_folders.remove(name);
|
|
|
|
|
selected_folders.add(0, name);
|
|
|
|
@ -140,6 +144,32 @@ public class FragmentDialogFolder extends FragmentDialogBase {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
tvFavorite1.setVisibility(View.GONE);
|
|
|
|
|
tvFavorite2.setVisibility(View.GONE);
|
|
|
|
|
tvFavorite3.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
tvFavorite1.setPaintFlags(tvFavorite1.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
|
|
|
|
tvFavorite2.setPaintFlags(tvFavorite2.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
|
|
|
|
tvFavorite3.setPaintFlags(tvFavorite3.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
|
|
|
|
|
|
|
|
|
View.OnClickListener listener = new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
Long id = (Long) v.getTag();
|
|
|
|
|
if (id == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Bundle args = getArguments();
|
|
|
|
|
args.putLong("folder", id);
|
|
|
|
|
|
|
|
|
|
sendResult(RESULT_OK);
|
|
|
|
|
dismiss();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
tvFavorite1.setOnClickListener(listener);
|
|
|
|
|
tvFavorite2.setOnClickListener(listener);
|
|
|
|
|
tvFavorite3.setOnClickListener(listener);
|
|
|
|
|
|
|
|
|
|
rvFolder.setAdapter(adapter);
|
|
|
|
|
|
|
|
|
|
etSearch.addTextChangedListener(new TextWatcher() {
|
|
|
|
@ -200,8 +230,9 @@ public class FragmentDialogFolder extends FragmentDialogBase {
|
|
|
|
|
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
args.putLong("account", account);
|
|
|
|
|
args.putLongArray("disabled", disabled);
|
|
|
|
|
|
|
|
|
|
new SimpleTask<List<TupleFolderEx>>() {
|
|
|
|
|
new SimpleTask<Data>() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void onPreExecute(Bundle args) {
|
|
|
|
|
tvNoFolder.setVisibility(View.GONE);
|
|
|
|
@ -215,20 +246,35 @@ public class FragmentDialogFolder extends FragmentDialogBase {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected List<TupleFolderEx> onExecute(Context context, Bundle args) {
|
|
|
|
|
protected Data onExecute(Context context, Bundle args) {
|
|
|
|
|
long account = args.getLong("account");
|
|
|
|
|
long[] disabled = args.getLongArray("disabled");
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
return db.folder().getFoldersEx(account);
|
|
|
|
|
|
|
|
|
|
Data data = new Data();
|
|
|
|
|
data.folders = db.folder().getFoldersEx(account);
|
|
|
|
|
data.favorites = db.folder().getFavoriteFolders(3, disabled);
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onExecuted(final Bundle args, List<TupleFolderEx> folders) {
|
|
|
|
|
if (folders == null || folders.size() == 0)
|
|
|
|
|
protected void onExecuted(final Bundle args, Data data) {
|
|
|
|
|
if (data.folders == null || data.folders.size() == 0)
|
|
|
|
|
tvNoFolder.setVisibility(View.VISIBLE);
|
|
|
|
|
else {
|
|
|
|
|
adapter.setDisabled(Helper.fromLongArray(disabled));
|
|
|
|
|
adapter.set(folders);
|
|
|
|
|
adapter.set(data.folders);
|
|
|
|
|
if (data.favorites != null) {
|
|
|
|
|
TextView[] tv = new TextView[]{tvFavorite1, tvFavorite2, tvFavorite3};
|
|
|
|
|
for (int i = 0; i < data.favorites.size(); i++) {
|
|
|
|
|
EntityFolder favorite = data.favorites.get(i);
|
|
|
|
|
tv[i].setTag(favorite.id);
|
|
|
|
|
tv[i].setText(favorite.getDisplayName(context));
|
|
|
|
|
tv[i].setVisibility(View.VISIBLE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
grpReady.setVisibility(View.VISIBLE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -246,4 +292,9 @@ public class FragmentDialogFolder extends FragmentDialogBase {
|
|
|
|
|
.setNegativeButton(android.R.string.cancel, null)
|
|
|
|
|
.create();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static class Data {
|
|
|
|
|
private List<TupleFolderEx> folders;
|
|
|
|
|
private List<EntityFolder> favorites;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|