mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-25 09:08:49 -05:00
move NetworkType to k9mail-library, use on StoreConfig
This commit is contained in:
parent
147db8cc5e
commit
110400a85b
@ -0,0 +1,25 @@
|
|||||||
|
package com.fsck.k9.mail;
|
||||||
|
|
||||||
|
import android.net.ConnectivityManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enum for some of
|
||||||
|
* https://developer.android.com/reference/android/net/ConnectivityManager.html#TYPE_MOBILE etc.
|
||||||
|
*/
|
||||||
|
public enum NetworkType {
|
||||||
|
|
||||||
|
WIFI,
|
||||||
|
MOBILE,
|
||||||
|
OTHER;
|
||||||
|
|
||||||
|
public static NetworkType fromConnectivityManagerType(int type){
|
||||||
|
switch (type) {
|
||||||
|
case ConnectivityManager.TYPE_MOBILE:
|
||||||
|
return MOBILE;
|
||||||
|
case ConnectivityManager.TYPE_WIFI:
|
||||||
|
return WIFI;
|
||||||
|
default:
|
||||||
|
return OTHER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,12 +1,14 @@
|
|||||||
package com.fsck.k9.mail.store;
|
package com.fsck.k9.mail.store;
|
||||||
|
|
||||||
|
|
||||||
|
import com.fsck.k9.mail.NetworkType;
|
||||||
|
|
||||||
public interface StoreConfig {
|
public interface StoreConfig {
|
||||||
String getStoreUri();
|
String getStoreUri();
|
||||||
String getTransportUri();
|
String getTransportUri();
|
||||||
|
|
||||||
boolean subscribedFoldersOnly();
|
boolean subscribedFoldersOnly();
|
||||||
boolean useCompression(int type);
|
boolean useCompression(NetworkType type);
|
||||||
|
|
||||||
String getInboxFolderName();
|
String getInboxFolderName();
|
||||||
String getOutboxFolderName();
|
String getOutboxFolderName();
|
||||||
|
@ -11,6 +11,7 @@ import com.fsck.k9.mail.CertificateValidationException;
|
|||||||
import com.fsck.k9.mail.ConnectionSecurity;
|
import com.fsck.k9.mail.ConnectionSecurity;
|
||||||
import com.fsck.k9.mail.K9MailLib;
|
import com.fsck.k9.mail.K9MailLib;
|
||||||
import com.fsck.k9.mail.MessagingException;
|
import com.fsck.k9.mail.MessagingException;
|
||||||
|
import com.fsck.k9.mail.NetworkType;
|
||||||
import com.fsck.k9.mail.filter.Base64;
|
import com.fsck.k9.mail.filter.Base64;
|
||||||
import com.fsck.k9.mail.filter.PeekableInputStream;
|
import com.fsck.k9.mail.filter.PeekableInputStream;
|
||||||
import com.fsck.k9.mail.ssl.TrustedSocketFactory;
|
import com.fsck.k9.mail.ssl.TrustedSocketFactory;
|
||||||
@ -471,7 +472,8 @@ class ImapConnection {
|
|||||||
if (K9MailLib.isDebug()) {
|
if (K9MailLib.isDebug()) {
|
||||||
Log.d(LOG_TAG, "On network type " + type);
|
Log.d(LOG_TAG, "On network type " + type);
|
||||||
}
|
}
|
||||||
useCompression = mSettings.useCompression(type);
|
useCompression = mSettings.useCompression(
|
||||||
|
NetworkType.fromConnectivityManagerType(type));
|
||||||
}
|
}
|
||||||
if (K9MailLib.isDebug()) {
|
if (K9MailLib.isDebug()) {
|
||||||
Log.d(LOG_TAG, "useCompression " + useCompression);
|
Log.d(LOG_TAG, "useCompression " + useCompression);
|
||||||
|
@ -2,6 +2,7 @@ package com.fsck.k9.mail.store.imap;
|
|||||||
|
|
||||||
import com.fsck.k9.mail.AuthType;
|
import com.fsck.k9.mail.AuthType;
|
||||||
import com.fsck.k9.mail.ConnectionSecurity;
|
import com.fsck.k9.mail.ConnectionSecurity;
|
||||||
|
import com.fsck.k9.mail.NetworkType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Settings source for IMAP. Implemented in order to remove coupling between {@link ImapStore} and {@link ImapConnection}.
|
* Settings source for IMAP. Implemented in order to remove coupling between {@link ImapStore} and {@link ImapConnection}.
|
||||||
@ -21,7 +22,7 @@ interface ImapSettings {
|
|||||||
|
|
||||||
String getClientCertificateAlias();
|
String getClientCertificateAlias();
|
||||||
|
|
||||||
boolean useCompression(int type);
|
boolean useCompression(NetworkType type);
|
||||||
|
|
||||||
String getPathPrefix();
|
String getPathPrefix();
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ import android.os.PowerManager;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.fsck.k9.mail.NetworkType;
|
||||||
import com.fsck.k9.mail.internet.MimeMessageHelper;
|
import com.fsck.k9.mail.internet.MimeMessageHelper;
|
||||||
import com.fsck.k9.mail.power.TracingPowerManager;
|
import com.fsck.k9.mail.power.TracingPowerManager;
|
||||||
import com.fsck.k9.mail.power.TracingPowerManager.TracingWakeLock;
|
import com.fsck.k9.mail.power.TracingPowerManager.TracingWakeLock;
|
||||||
@ -2932,7 +2933,7 @@ public class ImapStore extends RemoteStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean useCompression(final int type) {
|
public boolean useCompression(final NetworkType type) {
|
||||||
return mStoreConfig.useCompression(type);
|
return mStoreConfig.useCompression(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,8 @@ import com.fsck.k9.mail.AuthType;
|
|||||||
import com.fsck.k9.mail.AuthenticationFailedException;
|
import com.fsck.k9.mail.AuthenticationFailedException;
|
||||||
import com.fsck.k9.mail.ConnectionSecurity;
|
import com.fsck.k9.mail.ConnectionSecurity;
|
||||||
import com.fsck.k9.mail.MessagingException;
|
import com.fsck.k9.mail.MessagingException;
|
||||||
|
import com.fsck.k9.mail.NetworkType;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -167,7 +169,7 @@ public class ImapConnectionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean useCompression(int type) {
|
public boolean useCompression(NetworkType type) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ import com.fsck.k9.activity.setup.AccountSetupCheckSettings.CheckDirection;
|
|||||||
import com.fsck.k9.helper.Utility;
|
import com.fsck.k9.helper.Utility;
|
||||||
import com.fsck.k9.mail.Address;
|
import com.fsck.k9.mail.Address;
|
||||||
import com.fsck.k9.mail.MessagingException;
|
import com.fsck.k9.mail.MessagingException;
|
||||||
|
import com.fsck.k9.mail.NetworkType;
|
||||||
import com.fsck.k9.mail.Store;
|
import com.fsck.k9.mail.Store;
|
||||||
import com.fsck.k9.mail.Folder.FolderClass;
|
import com.fsck.k9.mail.Folder.FolderClass;
|
||||||
import com.fsck.k9.mail.filter.Base64;
|
import com.fsck.k9.mail.filter.Base64;
|
||||||
@ -96,12 +97,6 @@ public class Account implements BaseAccount, StoreConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum NetworkType {
|
|
||||||
WIFI,
|
|
||||||
MOBILE,
|
|
||||||
OTHER
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final MessageFormat DEFAULT_MESSAGE_FORMAT = MessageFormat.HTML;
|
public static final MessageFormat DEFAULT_MESSAGE_FORMAT = MessageFormat.HTML;
|
||||||
public static final boolean DEFAULT_MESSAGE_FORMAT_AUTO = false;
|
public static final boolean DEFAULT_MESSAGE_FORMAT_AUTO = false;
|
||||||
public static final boolean DEFAULT_MESSAGE_READ_RECEIPT = false;
|
public static final boolean DEFAULT_MESSAGE_READ_RECEIPT = false;
|
||||||
@ -1303,19 +1298,6 @@ public class Account implements BaseAccount, StoreConfig {
|
|||||||
return useCompression;
|
return useCompression;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean useCompression(int type) {
|
|
||||||
NetworkType networkType = NetworkType.OTHER;
|
|
||||||
switch (type) {
|
|
||||||
case ConnectivityManager.TYPE_MOBILE:
|
|
||||||
networkType = NetworkType.MOBILE;
|
|
||||||
break;
|
|
||||||
case ConnectivityManager.TYPE_WIFI:
|
|
||||||
networkType = NetworkType.WIFI;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return useCompression(networkType);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (o instanceof Account) {
|
if (o instanceof Account) {
|
||||||
|
@ -17,7 +17,7 @@ import android.widget.CompoundButton.OnCheckedChangeListener;
|
|||||||
|
|
||||||
import com.fsck.k9.*;
|
import com.fsck.k9.*;
|
||||||
import com.fsck.k9.Account.FolderMode;
|
import com.fsck.k9.Account.FolderMode;
|
||||||
import com.fsck.k9.Account.NetworkType;
|
import com.fsck.k9.mail.NetworkType;
|
||||||
import com.fsck.k9.activity.K9Activity;
|
import com.fsck.k9.activity.K9Activity;
|
||||||
import com.fsck.k9.activity.setup.AccountSetupCheckSettings.CheckDirection;
|
import com.fsck.k9.activity.setup.AccountSetupCheckSettings.CheckDirection;
|
||||||
import com.fsck.k9.helper.Utility;
|
import com.fsck.k9.helper.Utility;
|
||||||
|
Loading…
Reference in New Issue
Block a user