X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/465ff1b7b8b04132f58fdea80cdf12ce9a2e01fd..a99a28cc61d48eca63803c3d661ea1be14f99aec:/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java diff --git a/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java b/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java index 676a12c6..dc32ecc0 100644 --- a/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java +++ b/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java @@ -128,6 +128,12 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver { i.putExtra(FileUploader.KEY_INSTANT_UPLOAD, true); // instant upload behaviour + i = addInstantUploadBehaviour(i, context); + + context.startService(i); + } + + private Intent addInstantUploadBehaviour(Intent i, Context context){ SharedPreferences appPreferences = PreferenceManager.getDefaultSharedPreferences(context); String behaviour = appPreferences.getString("prefs_instant_behaviour", "NOTHING"); @@ -145,7 +151,7 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver { Log_OC.d(TAG, "upload file and delete file in original place"); } - context.startService(i); + return i; } private void handleNewVideoAction(Context context, Intent intent) { @@ -200,22 +206,7 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver { i.putExtra(FileUploader.KEY_INSTANT_UPLOAD, true); // instant upload behaviour - SharedPreferences appPreferences = PreferenceManager.getDefaultSharedPreferences(context); - String behaviour = appPreferences.getString("prefs_instant_behaviour", "NOTHING"); - - if (behaviour.equalsIgnoreCase("NOTHING")) { - Log_OC.d(TAG, "upload file and do nothing"); - i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_FORGET); - } else if (behaviour.equalsIgnoreCase("COPY")) { - i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_COPY); - Log_OC.d(TAG, "upload file and copy file to oc folder"); - } else if (behaviour.equalsIgnoreCase("MOVE")) { - i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_MOVE); - Log_OC.d(TAG, "upload file and move file to oc folder"); - } else if (behaviour.equalsIgnoreCase("DELETE")){ - i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_REMOVE); - Log_OC.d(TAG, "upload file and delete file in original place"); - } + i = addInstantUploadBehaviour(i, context); context.startService(i); @@ -227,6 +218,19 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver { return; } + if (instantPictureUploadViaWiFiOnly(context) && !isConnectedViaWiFi(context)){ + Account account = AccountUtils.getCurrentOwnCloudAccount(context); + if (account == null) { + Log_OC.w(TAG, "No owncloud account found for instant upload, aborting"); + return; + } + + Intent i = new Intent(context, FileUploader.class); + i.putExtra(FileUploader.KEY_ACCOUNT, account); + i.putExtra(FileUploader.KEY_CANCEL_ALL, true); + context.startService(i); + } + if (!intent.hasExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY) && isOnline(context) && (!instantUploadWhenChargingOnly(context) || (instantUploadWhenChargingOnly(context) && isCharging(context))) @@ -238,6 +242,11 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver { Cursor c = db.getAwaitingFiles(); if (c.moveToFirst()) { do { + if (instantPictureUploadViaWiFiOnly(context) && + !isConnectedViaWiFi(context)){ + break; + } + String account_name = c.getString(c.getColumnIndex("account")); String file_path = c.getString(c.getColumnIndex("path")); File f = new File(file_path); @@ -263,22 +272,7 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver { i.putExtra(FileUploader.KEY_INSTANT_UPLOAD, true); // instant upload behaviour - SharedPreferences appPreferences = PreferenceManager.getDefaultSharedPreferences(context); - String behaviour = appPreferences.getString("prefs_instant_behaviour", "NOTHING"); - - if (behaviour.equalsIgnoreCase("NOTHING")) { - Log_OC.d(TAG, "upload file and do nothing"); - i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_FORGET); - } else if (behaviour.equalsIgnoreCase("COPY")) { - i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_COPY); - Log_OC.d(TAG, "upload file and copy file to oc folder"); - } else if (behaviour.equalsIgnoreCase("MOVE")) { - i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_MOVE); - Log_OC.d(TAG, "upload file and move file to oc folder"); - } else if (behaviour.equalsIgnoreCase("DELETE")){ - i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_REMOVE); - Log_OC.d(TAG, "upload file and delete file in original place"); - } + i = addInstantUploadBehaviour(i, context); context.startService(i);