Merge pull request #152 from owncloud/oauth_login
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / activity / ConflictsResolveActivity.java
index 4867654..62c5f46 100644 (file)
@@ -1,10 +1,10 @@
 /* ownCloud Android client application
  *   Copyright (C) 2012 Bartek Przybylski
+ *   Copyright (C) 2012-2013 ownCloud Inc.
  *
  *   This program is free software: you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation, either version 3 of the License, or
- *   (at your option) any later version.
+ *   it under the terms of the GNU General Public License version 2,
+ *   as published by the Free Software Foundation.
  *
  *   This program is distributed in the hope that it will be useful,
  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -19,6 +19,8 @@
 package com.owncloud.android.ui.activity;
 
 import com.actionbarsherlock.app.SherlockFragmentActivity;
+import com.owncloud.android.Log_OC;
+import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.files.services.FileUploader;
 import com.owncloud.android.ui.dialog.ConflictsResolveDialog;
 import com.owncloud.android.ui.dialog.ConflictsResolveDialog.Decision;
@@ -27,7 +29,6 @@ import com.owncloud.android.ui.dialog.ConflictsResolveDialog.OnConflictDecisionM
 import android.accounts.Account;
 import android.content.Intent;
 import android.os.Bundle;
-import android.util.Log;
 
 /**
  * Wrapper activity which will be launched if keep-in-sync file will be modified by external
@@ -38,21 +39,27 @@ import android.util.Log;
  */
 public class ConflictsResolveActivity extends SherlockFragmentActivity implements OnConflictDecisionMadeListener {
 
+    public static final String EXTRA_FILE = "FILE";
+    public static final String EXTRA_ACCOUNT = "ACCOUNT";
+
     private String TAG = ConflictsResolveActivity.class.getSimpleName();
     
-    private String mRemotePath;
+    //private String mRemotePath;
     
-    private String mLocalPath;
+    //private String mLocalPath;
     
+    private OCFile mFile;
     private Account mOCAccount;
     
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        mRemotePath = getIntent().getStringExtra("remotepath");
-        mLocalPath = getIntent().getStringExtra("localpath");
-        mOCAccount = getIntent().getParcelableExtra("account");
-        ConflictsResolveDialog d = ConflictsResolveDialog.newInstance(mRemotePath, this);
+        
+        //mRemotePath = getIntent().getStringExtra("remotepath");
+        //mLocalPath = getIntent().getStringExtra("localpath");
+        mFile = getIntent().getParcelableExtra(EXTRA_FILE);
+        mOCAccount = getIntent().getParcelableExtra(EXTRA_ACCOUNT);
+        ConflictsResolveDialog d = ConflictsResolveDialog.newInstance(mFile.getRemotePath(), this);
         d.showDialog(this);
     }
 
@@ -66,15 +73,16 @@ public class ConflictsResolveActivity extends SherlockFragmentActivity implement
                 return;
             case OVERWRITE:
                 i.putExtra(FileUploader.KEY_FORCE_OVERWRITE, true);
-            case KEEP_BOTH: // fallthrough
+                break;
+            case KEEP_BOTH:
+                i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_MOVE);
                 break;
             default:
-                Log.wtf(TAG, "Unhandled conflict decision " + decision);
+                Log_OC.wtf(TAG, "Unhandled conflict decision " + decision);
                 return;
         }
         i.putExtra(FileUploader.KEY_ACCOUNT, mOCAccount);
-        i.putExtra(FileUploader.KEY_REMOTE_FILE, mRemotePath);
-        i.putExtra(FileUploader.KEY_LOCAL_FILE, mLocalPath);
+        i.putExtra(FileUploader.KEY_FILE, mFile);
         i.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_SINGLE_FILE);
         
         startService(i);