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); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
EntityFolder inbox = db.folder().getFolderByType(account, EntityFolder.INBOX); EntityFolder inbox = db.folder().getFolderByType(account, EntityFolder.INBOX);
if (inbox == null)
return null;
EntityFolder junk = db.folder().getFolderByType(account, EntityFolder.JUNK); 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( db.folder().setFolderAutoClassify(
inbox.id, inbox.auto_classify_source || filter, inbox.auto_classify_target); inbox.id, inbox.auto_classify_source || filter, inbox.auto_classify_target);
db.folder().setFolderDownload(
junk.id, junk.download || filter);
db.folder().setFolderAutoClassify( db.folder().setFolderAutoClassify(
junk.id, junk.auto_classify_source || filter, filter); 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; return null;
} }
@ -6531,8 +6550,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
return false; return false;
return (classification && return (classification &&
inbox.auto_classify_source && inbox.download && inbox.auto_classify_source &&
junk.auto_classify_source && junk.auto_classify_target); junk.download && junk.auto_classify_source && junk.auto_classify_target);
} }
@Override @Override

@ -346,6 +346,9 @@ public interface DaoFolder {
@Query("UPDATE folder SET poll_count = :count WHERE id = :id AND NOT (poll_count IS :count)") @Query("UPDATE folder SET poll_count = :count WHERE id = :id AND NOT (poll_count IS :count)")
int setFolderPollCount(long id, int 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" + @Query("UPDATE folder" +
" SET auto_classify_source = :source, auto_classify_target = :target" + " SET auto_classify_source = :source, auto_classify_target = :target" +
" WHERE id = :id" + " WHERE id = :id" +

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

Loading…
Cancel
Save