Disable change log; to remove in future
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / activity / ConflictsResolveActivity.java
1 /* ownCloud Android client application
2 * Copyright (C) 2012 Bartek Przybylski
3 * Copyright (C) 2012-2013 ownCloud Inc.
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 */
19
20 package com.owncloud.android.ui.activity;
21
22 import com.actionbarsherlock.app.SherlockFragmentActivity;
23 import com.owncloud.android.datamodel.OCFile;
24 import com.owncloud.android.files.services.FileUploader;
25 import com.owncloud.android.ui.dialog.ConflictsResolveDialog;
26 import com.owncloud.android.ui.dialog.ConflictsResolveDialog.Decision;
27 import com.owncloud.android.ui.dialog.ConflictsResolveDialog.OnConflictDecisionMadeListener;
28
29 import android.accounts.Account;
30 import android.content.Intent;
31 import android.os.Bundle;
32 import android.util.Log;
33
34 /**
35 * Wrapper activity which will be launched if keep-in-sync file will be modified by external
36 * application.
37 *
38 * @author Bartek Przybylski
39 *
40 */
41 public class ConflictsResolveActivity extends SherlockFragmentActivity implements OnConflictDecisionMadeListener {
42
43 public static final String EXTRA_FILE = "FILE";
44 public static final String EXTRA_ACCOUNT = "ACCOUNT";
45
46 private String TAG = ConflictsResolveActivity.class.getSimpleName();
47
48 //private String mRemotePath;
49
50 //private String mLocalPath;
51
52 private OCFile mFile;
53 private Account mOCAccount;
54
55 @Override
56 protected void onCreate(Bundle savedInstanceState) {
57 super.onCreate(savedInstanceState);
58
59 //mRemotePath = getIntent().getStringExtra("remotepath");
60 //mLocalPath = getIntent().getStringExtra("localpath");
61 mFile = getIntent().getParcelableExtra(EXTRA_FILE);
62 mOCAccount = getIntent().getParcelableExtra(EXTRA_ACCOUNT);
63 ConflictsResolveDialog d = ConflictsResolveDialog.newInstance(mFile.getRemotePath(), this);
64 d.showDialog(this);
65 }
66
67 @Override
68 public void ConflictDecisionMade(Decision decision) {
69 Intent i = new Intent(getApplicationContext(), FileUploader.class);
70
71 switch (decision) {
72 case CANCEL:
73 finish();
74 return;
75 case OVERWRITE:
76 i.putExtra(FileUploader.KEY_FORCE_OVERWRITE, true);
77 break;
78 case KEEP_BOTH:
79 i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_MOVE);
80 break;
81 default:
82 Log.wtf(TAG, "Unhandled conflict decision " + decision);
83 return;
84 }
85 i.putExtra(FileUploader.KEY_ACCOUNT, mOCAccount);
86 i.putExtra(FileUploader.KEY_FILE, mFile);
87 i.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_SINGLE_FILE);
88
89 startService(i);
90 finish();
91 }
92 }