Classification requires download

pull/191/head
M66B 4 years ago
parent 2a6bfda7b8
commit bc2c89d339

@ -6478,16 +6478,35 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
DB db = DB.getInstance(context);
EntityFolder inbox = db.folder().getFolderByType(account, EntityFolder.INBOX);
if (inbox == null)
return null;
EntityFolder junk = db.folder().getFolderByType(account, EntityFolder.JUNK);
if (inbox != null && junk != null) {
if (junk == null)
return null;
try {
db.beginTransaction();
db.folder().setFolderDownload(
inbox.id, inbox.download || filter);
db.folder().setFolderAutoClassify(
inbox.id, inbox.auto_classify_source || filter, inbox.auto_classify_target);
db.folder().setFolderDownload(
junk.id, junk.download || filter);
db.folder().setFolderAutoClassify(
junk.id, junk.auto_classify_source || filter, filter);
prefs.edit().putBoolean("classification", true).apply();
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
prefs.edit().putBoolean("classification", true).apply();
return null;
}
@ -6531,8 +6550,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
return false;
return (classification &&
inbox.auto_classify_source &&
junk.auto_classify_source && junk.auto_classify_target);
inbox.download && inbox.auto_classify_source &&
junk.download && junk.auto_classify_source && junk.auto_classify_target);
}
@Override

@ -346,6 +346,9 @@ public interface DaoFolder {
@Query("UPDATE folder SET poll_count = :count WHERE id = :id AND NOT (poll_count IS :count)")
int setFolderPollCount(long id, int count);
@Query("UPDATE folder SET download = :download WHERE id = :id AND NOT (download IS :download)")
int setFolderDownload(long id, boolean download);
@Query("UPDATE folder" +
" SET auto_classify_source = :source, auto_classify_target = :target" +
" WHERE id = :id" +

@ -181,19 +181,18 @@ public class FragmentFolder extends FragmentBase {
}
});
cbAutoClassifySource.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
cbDownload.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked)
cbDownload.setChecked(true);
cbAutoClassifySource.setEnabled(isChecked);
cbAutoClassifyTarget.setEnabled(isChecked && cbAutoClassifySource.isChecked());
}
});
cbAutoClassifyTarget.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
cbAutoClassifySource.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked)
cbAutoClassifySource.setChecked(true);
cbAutoClassifyTarget.setEnabled(isChecked);
}
});
@ -334,7 +333,8 @@ public class FragmentFolder extends FragmentBase {
etPoll.setEnabled(cbSynchronize.isChecked() && always);
tvPoll.setEnabled(cbSynchronize.isChecked() && always);
grpPoll.setVisibility(imap && cbPoll.isEnabled() && cbPoll.isChecked() ? View.VISIBLE : View.GONE);
cbAutoClassifyTarget.setEnabled(pro);
cbAutoClassifySource.setEnabled(cbDownload.isChecked());
cbAutoClassifyTarget.setEnabled(cbDownload.isChecked() && cbAutoClassifySource.isChecked());
cbAutoClassifySource.setVisibility(canAutoClassify ? View.VISIBLE : View.GONE);
cbAutoClassifyTarget.setVisibility(canAutoClassify ? View.VISIBLE : View.GONE);
tvAutoClassifyPro.setVisibility(canAutoClassify && !pro ? View.VISIBLE : View.GONE);

Loading…
Cancel
Save