Add keyword to multiple messages

master
M66B 1 week ago
parent 00bc2580f3
commit 22608ab9e5

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

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

Loading…
Cancel
Save