1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-21 23:32:51 +00:00

Add keyword to multiple messages

This commit is contained in:
M66B 2024-11-08 10:17:54 +01:00
parent 00bc2580f3
commit 22608ab9e5
2 changed files with 10 additions and 12 deletions

View file

@ -37,8 +37,7 @@ public class FragmentDialogKeywordAdd extends FragmentDialogBase {
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
final long id = getArguments().getLong("id");
Bundle args = getArguments();
final Context context = getContext();
View view = LayoutInflater.from(context).inflate(R.layout.dialog_keyword_add, null);
@ -52,25 +51,24 @@ public class FragmentDialogKeywordAdd extends FragmentDialogBase {
public void onClick(DialogInterface dialog, int which) {
String keyword = MessageHelper.sanitizeKeyword(etKeyword.getText().toString());
if (!TextUtils.isEmpty(keyword)) {
Bundle args = new Bundle();
args.putLong("id", id);
args.putString("keyword", keyword);
new SimpleTask<Void>() {
@Override
protected Void onExecute(Context context, Bundle args) {
long id = args.getLong("id");
long[] ids = args.getLongArray("ids");
String keyword = args.getString("keyword");
DB db = DB.getInstance(context);
try {
db.beginTransaction();
EntityMessage message = db.message().getMessage(id);
if (message == null)
return null;
EntityOperation.queue(context, message, EntityOperation.KEYWORD, keyword, true);
if (ids != null)
for (long id : ids) {
EntityMessage message = db.message().getMessage(id);
if (message != null)
EntityOperation.queue(context, message, EntityOperation.KEYWORD, keyword, true);
}
db.setTransactionSuccessful();
} finally {

View file

@ -64,7 +64,7 @@ public class FragmentDialogKeywordManage extends FragmentDialogBase {
@Override
public void onClick(View v) {
Bundle args = new Bundle();
args.putLong("id", id);
args.putLongArray("ids", new long[]{id});
FragmentDialogKeywordAdd fragment = new FragmentDialogKeywordAdd();
fragment.setArguments(args);
@ -101,7 +101,7 @@ public class FragmentDialogKeywordManage extends FragmentDialogBase {
.setIcon(R.drawable.twotone_label_important_24)
.setTitle(R.string.title_manage_keywords)
.setView(dview)
.setPositiveButton(android.R.string.ok, null)
.setNegativeButton(R.string.title_setup_done, null)
.create();
}