Debug providers

This commit is contained in:
M66B 2023-01-02 08:47:29 +01:00
parent a32ba0ebc9
commit cf58d1cb3f
3 changed files with 16 additions and 8 deletions

View File

@ -77,6 +77,7 @@ public class EmailProvider implements Parcelable {
public String id;
public String name;
public String description;
public boolean debug;
public boolean enabled;
public List<String> domain;
public List<String> mx;
@ -228,11 +229,8 @@ public class EmailProvider implements Parcelable {
if (provider.description == null)
provider.description = provider.name;
String enabled = xml.getAttributeValue(null, "enabled");
if ("debug".equals(enabled))
provider.enabled = BuildConfig.DEBUG;
else
provider.enabled = getAttributeBooleanValue(xml, "enabled", true);
provider.debug = getAttributeBooleanValue(xml, "debug", false);
provider.enabled = getAttributeBooleanValue(xml, "enabled", true);
String domain = xml.getAttributeValue(null, "domain");
if (domain != null)
@ -352,10 +350,15 @@ public class EmailProvider implements Parcelable {
return null;
}
// For user interface
static List<EmailProvider> getProviders(Context context) {
return getProviders(context, false);
}
static List<EmailProvider> getProviders(Context context, boolean debug) {
List<EmailProvider> result = new ArrayList<>();
for (EmailProvider provider : loadProfiles(context))
if (provider.enabled)
if (provider.enabled || (provider.debug && debug))
result.add(provider);
return result;
}

View File

@ -282,12 +282,16 @@ public class FragmentSetup extends FragmentBase implements SharedPreferences.OnS
@Override
public void onClick(View v) {
final Context context = getContext();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean debug = (prefs.getBoolean("debug", false) || BuildConfig.DEBUG);
PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(context, getViewLifecycleOwner(), btnQuick);
Menu menu = popupMenu.getMenu();
Resources res = context.getResources();
String pkg = context.getPackageName();
List<EmailProvider> providers = EmailProvider.getProviders(context);
List<EmailProvider> providers = EmailProvider.getProviders(context, debug);
int order = 1;

View File

@ -187,8 +187,9 @@
</provider>
<provider
name="Outlook"
debug="true"
description="Outlook/Office 365 (alt)"
enabled="debug"
enabled="false"
id="outlook"
link="https://github.com/M66B/FairEmail/blob/master/FAQ.md#user-content-faq14"
maxtls="1.2"