Classifier: pro feature

This commit is contained in:
M66B 2021-01-10 18:43:23 +01:00
parent db118959eb
commit 1e3d857b6d
3 changed files with 24 additions and 3 deletions

View File

@ -70,6 +70,7 @@ public class FragmentFolder extends FragmentBase {
private TextView tvPoll;
private CheckBox cbDownload;
private CheckBox cbAutoClassify;
private TextView tvAutoClassifyPro;
private Button btnInfo;
private EditText etSyncDays;
private EditText etKeepDays;
@ -131,6 +132,7 @@ public class FragmentFolder extends FragmentBase {
tvPoll = view.findViewById(R.id.tvPoll);
cbDownload = view.findViewById(R.id.cbDownload);
cbAutoClassify = view.findViewById(R.id.cbAutoClassify);
tvAutoClassifyPro = view.findViewById(R.id.tvAutoClassifyPro);
btnInfo = view.findViewById(R.id.btnInfo);
etSyncDays = view.findViewById(R.id.etSyncDays);
etKeepDays = view.findViewById(R.id.etKeepDays);
@ -177,6 +179,8 @@ public class FragmentFolder extends FragmentBase {
}
});
Helper.linkPro(tvAutoClassifyPro);
btnInfo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -218,6 +222,7 @@ public class FragmentFolder extends FragmentBase {
tvParent.setText(parent);
grpParent.setVisibility(parent == null ? View.GONE : View.VISIBLE);
cbAutoClassify.setVisibility(View.GONE);
tvAutoClassifyPro.setVisibility(View.GONE);
grpAutoDelete.setVisibility(View.GONE);
btnSave.setEnabled(false);
pbSave.setVisibility(View.GONE);
@ -303,13 +308,16 @@ public class FragmentFolder extends FragmentBase {
boolean canAutoClassify = (imap &&
MessageClassifier.isEnabled(getContext()) &&
(folder == null || MessageClassifier.canClassify(folder.type)));
boolean pro = (ActivityBilling.isPro(getContext()) ||
(folder != null && EntityFolder.JUNK.equals(folder.type)));
etName.setEnabled(folder == null || EntityFolder.USER.equals(folder.type));
cbPoll.setEnabled(cbSynchronize.isChecked() && always);
etPoll.setEnabled(cbSynchronize.isChecked() && always);
tvPoll.setEnabled(cbSynchronize.isChecked() && always);
grpPoll.setVisibility(imap && cbPoll.isEnabled() && cbPoll.isChecked() ? View.VISIBLE : View.GONE);
cbAutoClassify.setVisibility(canAutoClassify ? View.VISIBLE : View.GONE);
cbAutoClassify.setVisibility(canAutoClassify && pro ? View.VISIBLE : View.GONE);
tvAutoClassifyPro.setVisibility(canAutoClassify && !pro ? View.VISIBLE : View.GONE);
etKeepDays.setEnabled(!cbKeepAll.isChecked());
cbAutoDelete.setEnabled(!cbKeepAll.isChecked());
cbAutoDelete.setText(folder != null && EntityFolder.TRASH.equals(folder.type)

View File

@ -102,12 +102,15 @@ public class MessageClassifier {
!TextUtils.isEmpty(message.msgid) &&
!accountMsgIds.get(folder.account).contains(message.msgid) &&
!EntityFolder.JUNK.equals(folder.type)) {
boolean pro = ActivityBilling.isPro(context);
DB db = DB.getInstance(context);
try {
db.beginTransaction();
EntityFolder dest = db.folder().getFolderByName(folder.account, classified);
if (dest != null && dest.auto_classify) {
if (dest != null && dest.auto_classify &&
(pro || EntityFolder.JUNK.equals(dest.type))) {
EntityOperation.queue(context, message, EntityOperation.MOVE, dest.id, false, true);
message.ui_hide = true;
}

View File

@ -206,6 +206,16 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbDownload" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvAutoClassifyPro"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/title_pro_feature"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorLink"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbAutoClassify" />
<!-- after -->
<eu.faircode.email.FixedTextView
@ -216,7 +226,7 @@
android:text="@string/title_sync_days"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbAutoClassify" />
app:layout_constraintTop_toBottomOf="@id/tvAutoClassifyPro" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvSyncDaysRemark"