Allow keywords for POP3

This commit is contained in:
M66B
2025-02-21 10:20:19 +01:00
parent 7705704994
commit d6debbb616
5 changed files with 33 additions and 12 deletions

View File

@@ -2367,7 +2367,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean trash = (move || outbox || debug || pop);
boolean inbox = (move && hasInbox && (inArchive || inTrash || inJunk) && imap) ||
(pop && message.accountLeaveDeleted && inTrash);
boolean keywords = (message.uid != null && imap);
boolean keywords = (message.uid != null || pop);
boolean labels = (data.isGmail && move && !inTrash && !inJunk && !outbox);
boolean seen = (message.uid != null || pop);
@@ -6459,8 +6459,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
popupMenu.getMenu().findItem(R.id.menu_create_rule).setVisible(!message.folderReadOnly);
popupMenu.getMenu().findItem(R.id.menu_manage_keywords)
.setEnabled(message.uid != null)
.setVisible(message.accountProtocol == EntityAccount.TYPE_IMAP);
.setEnabled(message.uid != null || message.accountProtocol == EntityAccount.TYPE_POP);
popupMenu.getMenu().findItem(R.id.menu_search_in_text).setEnabled(message.content && !full);
popupMenu.getMenu().findItem(R.id.menu_translate).setVisible(
@@ -7550,6 +7549,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private void onMenuManageKeywords(TupleMessageEx message) {
Bundle args = new Bundle();
args.putLongArray("ids", new long[]{message.id});
args.putBoolean("pop", message.accountProtocol == EntityAccount.TYPE_POP);
FragmentDialogKeywordManage fragment = new FragmentDialogKeywordManage();
fragment.setArguments(args);

View File

@@ -26,6 +26,7 @@ import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -43,6 +44,7 @@ import java.util.List;
public class FragmentDialogKeywordManage extends FragmentDialogBase {
private View dview;
private TextView tvPop;
private RecyclerView rvKeyword;
private FloatingActionButton fabAdd;
private ContentLoadingProgressBar pbWait;
@@ -52,13 +54,18 @@ public class FragmentDialogKeywordManage extends FragmentDialogBase {
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
final Bundle args = getArguments();
long[] ids = args.getLongArray("ids");
boolean pop = args.getBoolean("pop");
final Context context = getContext();
dview = LayoutInflater.from(context).inflate(R.layout.dialog_keyword_manage, null);
tvPop = dview.findViewById(R.id.tvPop);
rvKeyword = dview.findViewById(R.id.rvKeyword);
fabAdd = dview.findViewById(R.id.fabAdd);
pbWait = dview.findViewById(R.id.pbWait);
tvPop.setVisibility(pop ? View.VISIBLE : View.GONE);
rvKeyword.setHasFixedSize(false);
final LinearLayoutManager llm = new LinearLayoutManager(context);
rvKeyword.setLayoutManager(llm);
@@ -78,7 +85,6 @@ public class FragmentDialogKeywordManage extends FragmentDialogBase {
pbWait.setVisibility(View.VISIBLE);
long[] ids = args.getLongArray("ids");
if (ids.length == 1) {
DB db = DB.getInstance(context);
db.message().liveMessageKeywords(ids[0]).observe(getViewLifecycleOwner(), new Observer<TupleKeyword.Persisted>() {

View File

@@ -1851,8 +1851,9 @@ public class FragmentMessages extends FragmentBase
ibKeywords.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MoreResult result = (MoreResult) cardMore.getTag();
boolean more_clear = prefs.getBoolean("more_clear", true);
onActionManageKeywords(more_clear);
onActionManageKeywords(more_clear, (result != null && result.hasPop));
}
});
@@ -4696,9 +4697,8 @@ public class FragmentMessages extends FragmentBase
popupMenu.getMenu().add(Menu.FIRST, R.string.title_copy_to, order++, R.string.title_copy_to)
.setIcon(R.drawable.twotone_file_copy_24);
if (!result.hasPop && result.hasImap)
popupMenu.getMenu().add(Menu.FIRST, R.string.title_manage_keywords, order++, R.string.title_manage_keywords)
.setIcon(R.drawable.twotone_label_important_24);
popupMenu.getMenu().add(Menu.FIRST, R.string.title_manage_keywords, order++, R.string.title_manage_keywords)
.setIcon(R.drawable.twotone_label_important_24);
if (ids.length == 1)
popupMenu.getMenu().add(Menu.FIRST, R.string.title_search_sender, order++, R.string.title_search_sender)
@@ -4773,7 +4773,7 @@ public class FragmentMessages extends FragmentBase
onActionMoveSelectionAccount(result.copyto.id, true, result.folders);
return true;
} else if (itemId == R.string.title_manage_keywords) {
onActionManageKeywords(false);
onActionManageKeywords(false, result.hasPop);
return true;
} else if (itemId == R.string.title_search_sender) {
long[] ids = getSelection();
@@ -5296,9 +5296,10 @@ public class FragmentMessages extends FragmentBase
fragment.show(getParentFragmentManager(), "messages:move");
}
private void onActionManageKeywords(boolean clear) {
private void onActionManageKeywords(boolean clear, boolean pop) {
Bundle args = new Bundle();
args.putLongArray("ids", getSelection());
args.putBoolean("pop", pop);
FragmentDialogKeywordManage fragment = new FragmentDialogKeywordManage();
fragment.setArguments(args);
@@ -7454,7 +7455,7 @@ public class FragmentMessages extends FragmentBase
if (inbox)
count++;
boolean keywords = (more_keywords && count < FragmentDialogQuickActions.MAX_QUICK_ACTIONS && !result.hasPop && result.hasImap);
boolean keywords = (more_keywords && count < FragmentDialogQuickActions.MAX_QUICK_ACTIONS);
if (keywords)
count++;