Allow keywords for POP3

pull/217/head
M66B 7 months ago
parent 7705704994
commit d6debbb616

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

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

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

@ -5,6 +5,19 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="12dp"> android:padding="12dp">
<TextView
android:id="@+id/tvPop"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:text="@string/title_manage_keywords_pop"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintBottom_toTopOf="@+id/rvKeyword"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<eu.faircode.email.FixedRecyclerView <eu.faircode.email.FixedRecyclerView
android:id="@+id/rvKeyword" android:id="@+id/rvKeyword"
android:layout_width="0dp" android:layout_width="0dp"
@ -19,7 +32,7 @@
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toBottomOf="@+id/tvPop" />
<com.google.android.material.floatingactionbutton.FloatingActionButton <com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fabAdd" android:id="@+id/fabAdd"

@ -1584,6 +1584,7 @@
<string name="title_raw_send_message">Message</string> <string name="title_raw_send_message">Message</string>
<string name="title_raw_send_thread">Conversation</string> <string name="title_raw_send_thread">Conversation</string>
<string name="title_manage_keywords">Manage keywords</string> <string name="title_manage_keywords">Manage keywords</string>
<string name="title_manage_keywords_pop">With POP3, keywords cannot be stored on the email server!</string>
<string name="title_manage_labels">Manage Gmail labels</string> <string name="title_manage_labels">Manage Gmail labels</string>
<string name="title_add_keyword">Add keyword</string> <string name="title_add_keyword">Add keyword</string>
<string name="title_show_inline">Show inline attachments</string> <string name="title_show_inline">Show inline attachments</string>

Loading…
Cancel
Save