diff --git a/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java b/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java index 27a5b86055..5a948413cb 100644 --- a/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java +++ b/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java @@ -25,8 +25,6 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.database.Cursor; -import android.net.ConnectivityManager; -import android.net.NetworkInfo.State; import android.preference.PreferenceManager; import android.provider.MediaStore.Images; import android.provider.MediaStore.Video; @@ -214,18 +212,6 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver { // // } - public static boolean isOnline(Context context) { - ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); - return cm.getActiveNetworkInfo() != null && cm.getActiveNetworkInfo().isConnected(); - } - - public static boolean isConnectedViaWiFi(Context context) { - ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); - return cm != null && cm.getActiveNetworkInfo() != null - && cm.getActiveNetworkInfo().getType() == ConnectivityManager.TYPE_WIFI - && cm.getActiveNetworkInfo().getState() == State.CONNECTED; - } - public static boolean instantPictureUploadEnabled(Context context) { return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("instant_uploading", false); } diff --git a/src/com/owncloud/android/files/services/FileUploadService.java b/src/com/owncloud/android/files/services/FileUploadService.java index 186c4383dd..f0710ccec3 100644 --- a/src/com/owncloud/android/files/services/FileUploadService.java +++ b/src/com/owncloud/android/files/services/FileUploadService.java @@ -55,7 +55,6 @@ import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.db.UploadDbHandler; import com.owncloud.android.db.UploadDbHandler.UploadStatus; import com.owncloud.android.db.UploadDbObject; -import com.owncloud.android.files.InstantUploadBroadcastReceiver; import com.owncloud.android.lib.common.OwnCloudAccount; import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.OwnCloudClientManagerFactory; @@ -258,7 +257,7 @@ public class FileUploadService extends IntentService { } //TODO This service can be instantiated at any time. Better move this retry call to start of app. - if(InstantUploadBroadcastReceiver.isOnline(getApplicationContext())) { + if(UploadUtils.isOnline(getApplicationContext())) { Log_OC.d(TAG, "FileUploadService.retry() called by onCreate()"); FileUploadService.retry(getApplicationContext()); } @@ -615,7 +614,7 @@ public class FileUploadService extends IntentService { } if (uploadDbObject.isUseWifiOnly() - && !InstantUploadBroadcastReceiver.isConnectedViaWiFi(getApplicationContext())) { + && !UploadUtils.isConnectedViaWiFi(getApplicationContext())) { Log_OC.d(TAG, "Do not start upload because it is wifi-only."); return CanUploadFileNowStatus.LATER; } diff --git a/src/com/owncloud/android/utils/UploadUtils.java b/src/com/owncloud/android/utils/UploadUtils.java index d7de06caf1..b5da42bee4 100755 --- a/src/com/owncloud/android/utils/UploadUtils.java +++ b/src/com/owncloud/android/utils/UploadUtils.java @@ -3,6 +3,8 @@ package com.owncloud.android.utils; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.net.ConnectivityManager; +import android.net.NetworkInfo.State; import android.os.BatteryManager; @@ -15,4 +17,16 @@ public class UploadUtils { int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1); return status == BatteryManager.BATTERY_STATUS_CHARGING || status == BatteryManager.BATTERY_STATUS_FULL; } + + public static boolean isOnline(Context context) { + ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); + return cm.getActiveNetworkInfo() != null && cm.getActiveNetworkInfo().isConnected(); + } + + public static boolean isConnectedViaWiFi(Context context) { + ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); + return cm != null && cm.getActiveNetworkInfo() != null + && cm.getActiveNetworkInfo().getType() == ConnectivityManager.TYPE_WIFI + && cm.getActiveNetworkInfo().getState() == State.CONNECTED; + } }