fixup! instant upload via wifi only - fixes
authorBartek Przybylski <bart.p.pl@gmail.com>
Wed, 10 Oct 2012 20:08:13 +0000 (22:08 +0200)
committerBartek Przybylski <bart.p.pl@gmail.com>
Wed, 10 Oct 2012 20:08:13 +0000 (22:08 +0200)
src/com/owncloud/android/db/DbHandler.java
src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java
src/com/owncloud/android/syncadapter/FileSyncAdapter.java

index ecc4098..01518ba 100644 (file)
@@ -69,8 +69,8 @@ public class DbHandler {
      */\r
     public boolean removeIUPendingFile(String localPath, String accountName) {\r
         return mDB.delete(TABLE_INSTANT_UPLOAD,\r
      */\r
     public boolean removeIUPendingFile(String localPath, String accountName) {\r
         return mDB.delete(TABLE_INSTANT_UPLOAD,\r
-                          "path = ? and account = ?",\r
-                          new String[]{ localPath, accountName }) != 0;\r
+                          "path = ?",\r
+                          new String[]{ localPath }) != 0;\r
         \r
     }\r
     \r
         \r
     }\r
     \r
index f0c6004..3c07238 100644 (file)
@@ -50,6 +50,7 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver {
     
     @Override
     public void onReceive(Context context, Intent intent) {
     
     @Override
     public void onReceive(Context context, Intent intent) {
+        Log.d(TAG, "Received: " + intent.getAction());
         if (intent.getAction().equals(android.net.ConnectivityManager.CONNECTIVITY_ACTION)) {
             handleConnectivityAction(context, intent);
         } else if (intent.getAction().equals(NEW_PHOTO_ACTION)) {
         if (intent.getAction().equals(android.net.ConnectivityManager.CONNECTIVITY_ACTION)) {
             handleConnectivityAction(context, intent);
         } else if (intent.getAction().equals(NEW_PHOTO_ACTION)) {
@@ -86,7 +87,9 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver {
             return;
         }
 
             return;
         }
 
-        Cursor c = context.getContentResolver().query(intent.getData(), CONTENT_PROJECTION, null, null, null);
+        Cursor c = context.getContentResolver().query(intent.getData(),
+                                                      CONTENT_PROJECTION,
+                                                      null, null, null);
         
         if (!c.moveToFirst()) {
             Log.e(TAG, "Couldn't resolve given uri: " + intent.getDataString());
         
         if (!c.moveToFirst()) {
             Log.e(TAG, "Couldn't resolve given uri: " + intent.getDataString());
@@ -98,6 +101,7 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver {
         String mime_type = c.getString(c.getColumnIndex(Media.MIME_TYPE));
 
         c.close();
         String mime_type = c.getString(c.getColumnIndex(Media.MIME_TYPE));
 
         c.close();
+        Log.e(TAG, file_path+"");
         
         if (!isOnline(context) ||
             (instantUploadViaWiFiOnly(context) && !isConnectedViaWiFi(context))) {
         
         if (!isOnline(context) ||
             (instantUploadViaWiFiOnly(context) && !isConnectedViaWiFi(context))) {
@@ -114,7 +118,7 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver {
         // On the other hand this might be only for dynamicly registered
         // broadcast receivers, needs investigation.
         IntentFilter filter = new IntentFilter(FileUploader.UPLOAD_FINISH_MESSAGE);
         // On the other hand this might be only for dynamicly registered
         // broadcast receivers, needs investigation.
         IntentFilter filter = new IntentFilter(FileUploader.UPLOAD_FINISH_MESSAGE);
-        context.registerReceiver(this, filter);
+        context.getApplicationContext().registerReceiver(this, filter);
                 
         Intent i = new Intent(context, FileUploader.class);
         i.putExtra(FileUploader.KEY_ACCOUNT, account);
                 
         Intent i = new Intent(context, FileUploader.class);
         i.putExtra(FileUploader.KEY_ACCOUNT, account);
@@ -140,6 +144,8 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver {
             DbHandler db = new DbHandler(context);
             Cursor c = db.getAwaitingFiles();
             if (c.moveToFirst()) {
             DbHandler db = new DbHandler(context);
             Cursor c = db.getAwaitingFiles();
             if (c.moveToFirst()) {
+                IntentFilter filter = new IntentFilter(FileUploader.UPLOAD_FINISH_MESSAGE);
+                context.getApplicationContext().registerReceiver(this, filter);
                 do {
                     String account_name = c.getString(c.getColumnIndex("account"));
                     String file_path = c.getString(c.getColumnIndex("path"));
                 do {
                     String account_name = c.getString(c.getColumnIndex("account"));
                     String file_path = c.getString(c.getColumnIndex("path"));
index e55d618..0088899 100644 (file)
@@ -90,8 +90,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
         mDelaysIndex = 0;\r
         mDelaysCount = 0;\r
         */\r
         mDelaysIndex = 0;\r
         mDelaysCount = 0;\r
         */\r
-        \r
-        \r
+\r
         Log.d(TAG, "syncing owncloud account " + account.name);\r
 \r
         sendStickyBroadcast(true, null);  // message to signal the start to the UI\r
         Log.d(TAG, "syncing owncloud account " + account.name);\r
 \r
         sendStickyBroadcast(true, null);  // message to signal the start to the UI\r
@@ -114,7 +113,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
                         fetchData(uri, syncResult, file.getFileId());\r
                     }\r
                 }\r
                         fetchData(uri, syncResult, file.getFileId());\r
                     }\r
                 }\r
-                \r
+\r
             } else {\r
                 syncResult.stats.numAuthExceptions++;\r
             }\r
             } else {\r
                 syncResult.stats.numAuthExceptions++;\r
             }\r