public boolean isConnectionStateOk(ConnectionState connectionState) { switch (this) { case ANY: return true; default: switch (connectionState) { case ONLINE: switch (this) { case SYNC: return !MyPreferences.isSyncOverWiFiOnly(); case DOWNLOAD_ATTACHMENT: return !MyPreferences.isSyncOverWiFiOnly() && !MyPreferences.isDownloadAttachmentsOverWiFiOnly(); case OFFLINE: return false; default: return true; } case WIFI: return (this != ConnectionRequired.OFFLINE); case OFFLINE: return (this == ConnectionRequired.OFFLINE); default: return true; } } }