Add OnlyFetchMvbox option (#2206)

* [WIP] Add OnlyFetchMvbox option

* Update res/values/strings.xml

* Adapt to the core changes

* Update res/values/strings.xml

Co-authored-by: bjoern <r10s@b44t.com>

* Remove unnecessary startIo() addition

* Update res/values/strings.xml

Co-authored-by: bjoern <r10s@b44t.com>

Co-authored-by: bjoern <r10s@b44t.com>
This commit is contained in:
Hocuri 2022-01-31 17:47:52 +01:00 committed by GitHub
parent 4607af4459
commit 0bc9f4735c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 7 deletions

View file

@ -607,6 +607,8 @@
<string name="pref_send_copy_to_self">Send Copy to Self</string>
<string name="pref_auto_folder_moves">Automatic Moves to DeltaChat Folder</string>
<string name="pref_auto_folder_moves_explain">Chat conversations are moved to avoid cluttering the Inbox</string>
<string name="pref_only_fetch_mvbox_title">Only Fetch from DeltaChat Folder</string>
<string name="pref_only_fetch_mvbox_explain">Ignore other folders. Requires your server to move chat messages to the DeltaChat folder.</string>
<string name="pref_show_emails">Show Classic E-Mails</string>
<string name="pref_show_emails_no">No, chats only</string>
<string name="pref_show_emails_accepted_contacts">For accepted contacts</string>

View file

@ -36,6 +36,12 @@
android:title="@string/pref_auto_folder_moves"
android:summary="@string/pref_auto_folder_moves_explain"/>
<org.thoughtcrime.securesms.components.SwitchPreferenceCompat
android:defaultValue="false"
android:key="pref_only_fetch_mvbox"
android:title="@string/pref_only_fetch_mvbox_title"
android:summary="@string/pref_only_fetch_mvbox_explain" />
</PreferenceCategory>

View file

@ -58,6 +58,7 @@ public class DcHelper {
public static final String CONFIG_SENTBOX_WATCH = "sentbox_watch";
public static final String CONFIG_MVBOX_WATCH = "mvbox_watch";
public static final String CONFIG_MVBOX_MOVE = "mvbox_move";
public static final String CONFIG_ONLY_FETCH_MVBOX = "only_fetch_mvbox";
public static final String CONFIG_BCC_SELF = "bcc_self";
public static final String CONFIG_SHOW_EMAILS = "show_emails";
public static final String CONFIG_MEDIA_QUALITY = "media_quality";

View file

@ -1,5 +1,13 @@
package org.thoughtcrime.securesms.preferences;
import static android.app.Activity.RESULT_OK;
import static android.text.InputType.TYPE_TEXT_VARIATION_URI;
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_BCC_SELF;
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_E2EE_ENABLED;
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_MVBOX_MOVE;
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_ONLY_FETCH_MVBOX;
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_SENTBOX_WATCH;
import android.Manifest;
import android.content.Context;
import android.content.DialogInterface;
@ -32,13 +40,6 @@ import org.thoughtcrime.securesms.util.ScreenLockUtil;
import org.thoughtcrime.securesms.util.Util;
import org.thoughtcrime.securesms.util.views.ProgressDialog;
import static android.app.Activity.RESULT_OK;
import static android.text.InputType.TYPE_TEXT_VARIATION_URI;
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_BCC_SELF;
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_E2EE_ENABLED;
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_MVBOX_MOVE;
import static org.thoughtcrime.securesms.connect.DcHelper.CONFIG_SENTBOX_WATCH;
public class AdvancedPreferenceFragment extends ListSummaryPreferenceFragment
implements DcEventCenter.DcEventDelegate
@ -52,6 +53,7 @@ public class AdvancedPreferenceFragment extends ListSummaryPreferenceFragment
CheckBoxPreference sentboxWatchCheckbox;
CheckBoxPreference bccSelfCheckbox;
CheckBoxPreference mvboxMoveCheckbox;
CheckBoxPreference onlyFetchMvboxCheckbox;
@Override
public void onCreate(Bundle paramBundle) {
@ -82,10 +84,21 @@ public class AdvancedPreferenceFragment extends ListSummaryPreferenceFragment
mvboxMoveCheckbox = (CheckBoxPreference) this.findPreference("pref_mvbox_move");
mvboxMoveCheckbox.setOnPreferenceChangeListener((preference, newValue) -> {
boolean enabled = (Boolean) newValue;
DcHelper.getAccounts(getContext()).stopIo();
dcContext.setConfigInt(CONFIG_MVBOX_MOVE, enabled? 1 : 0);
DcHelper.getAccounts(getContext()).startIo();
return true;
});
onlyFetchMvboxCheckbox = this.findPreference("pref_only_fetch_mvbox");
onlyFetchMvboxCheckbox.setOnPreferenceChangeListener(((preference, newValue) -> {
boolean enabled = (Boolean) newValue;
DcHelper.getAccounts(getContext()).stopIo();
dcContext.setConfigInt(CONFIG_ONLY_FETCH_MVBOX, enabled? 1 : 0);
DcHelper.getAccounts(getContext()).startIo();
return true;
}));
Preference manageKeys = this.findPreference("pref_manage_keys");
manageKeys.setOnPreferenceClickListener(new ManageKeysListener());
@ -151,6 +164,7 @@ public class AdvancedPreferenceFragment extends ListSummaryPreferenceFragment
sentboxWatchCheckbox.setChecked(0!=dcContext.getConfigInt(CONFIG_SENTBOX_WATCH));
bccSelfCheckbox.setChecked(0!=dcContext.getConfigInt(CONFIG_BCC_SELF));
mvboxMoveCheckbox.setChecked(0!=dcContext.getConfigInt(CONFIG_MVBOX_MOVE));
onlyFetchMvboxCheckbox.setChecked(0!=dcContext.getConfigInt(CONFIG_ONLY_FETCH_MVBOX));
}
@Override