1 /* ownCloud Android client application
2 * Copyright (C) 2012 Bartek Przybylski
3 * Copyright (C) 2012-2013 ownCloud Inc.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2,
7 * as published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 package com
.owncloud
.android
.ui
.activity
;
21 import com
.owncloud
.android
.Log_OC
;
22 import com
.owncloud
.android
.datamodel
.DataStorageManager
;
23 import com
.owncloud
.android
.datamodel
.FileDataStorageManager
;
24 import com
.owncloud
.android
.datamodel
.OCFile
;
25 import com
.owncloud
.android
.files
.services
.FileUploader
;
26 import com
.owncloud
.android
.ui
.dialog
.ConflictsResolveDialog
;
27 import com
.owncloud
.android
.ui
.dialog
.ConflictsResolveDialog
.Decision
;
28 import com
.owncloud
.android
.ui
.dialog
.ConflictsResolveDialog
.OnConflictDecisionMadeListener
;
30 import android
.content
.Intent
;
31 import android
.os
.Bundle
;
34 * Wrapper activity which will be launched if keep-in-sync file will be modified by external
37 * @author Bartek Przybylski
38 * @author David A. Velasco
40 public class ConflictsResolveActivity
extends FileActivity
implements OnConflictDecisionMadeListener
{
42 private String TAG
= ConflictsResolveActivity
.class.getSimpleName();
45 protected void onCreate(Bundle savedInstanceState
) {
46 super.onCreate(savedInstanceState
);
50 public void ConflictDecisionMade(Decision decision
) {
51 Intent i
= new Intent(getApplicationContext(), FileUploader
.class);
58 i
.putExtra(FileUploader
.KEY_FORCE_OVERWRITE
, true
);
61 i
.putExtra(FileUploader
.KEY_LOCAL_BEHAVIOUR
, FileUploader
.LOCAL_BEHAVIOUR_MOVE
);
64 Log_OC
.wtf(TAG
, "Unhandled conflict decision " + decision
);
67 i
.putExtra(FileUploader
.KEY_ACCOUNT
, getAccount());
68 i
.putExtra(FileUploader
.KEY_FILE
, getFile());
69 i
.putExtra(FileUploader
.KEY_UPLOAD_TYPE
, FileUploader
.UPLOAD_SINGLE_FILE
);
76 protected void onAccountSet(boolean stateWasRecovered
) {
77 if (getAccount() != null
) {
78 OCFile file
= getFile();
79 if (getFile() == null
) {
80 Log_OC
.e(TAG
, "No conflictive file received");
83 /// Check whether the 'main' OCFile handled by the Activity is contained in the current Account
84 DataStorageManager storageManager
= new FileDataStorageManager(getAccount(), getContentResolver());
85 file
= storageManager
.getFileByPath(file
.getRemotePath()); // file = null if not in the current Account
88 ConflictsResolveDialog d
= ConflictsResolveDialog
.newInstance(file
.getRemotePath(), this);
92 // account was changed to a different one - just finish
98 Log_OC
.wtf(TAG
, "onAccountChanged was called with NULL account associated!");