2 * ownCloud Android client application
4 * @author Bartek Przybylski
5 * @author David A. Velasco
6 * Copyright (C) 2012 Bartek Przybylski
7 * Copyright (C) 2015 ownCloud Inc.
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2,
11 * as published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 package com
.owncloud
.android
.ui
.activity
;
25 import android
.content
.Intent
;
26 import android
.os
.Bundle
;
28 import com
.owncloud
.android
.datamodel
.OCFile
;
29 import com
.owncloud
.android
.files
.services
.FileDownloader
;
30 import com
.owncloud
.android
.files
.services
.FileUploader
;
31 import com
.owncloud
.android
.lib
.common
.utils
.Log_OC
;
32 import com
.owncloud
.android
.ui
.dialog
.ConflictsResolveDialog
;
33 import com
.owncloud
.android
.ui
.dialog
.ConflictsResolveDialog
.Decision
;
34 import com
.owncloud
.android
.ui
.dialog
.ConflictsResolveDialog
.OnConflictDecisionMadeListener
;
37 * Wrapper activity which will be launched if keep-in-sync file will be modified by external
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 // use local version -> overwrite on server
59 i
.putExtra(FileUploader
.KEY_FORCE_OVERWRITE
, true
);
62 i
.putExtra(FileUploader
.KEY_LOCAL_BEHAVIOUR
, FileUploader
.LOCAL_BEHAVIOUR_MOVE
);
65 // use server version -> delete local, request download
66 Intent intent
= new Intent(this, FileDownloader
.class);
67 intent
.putExtra(FileDownloader
.EXTRA_ACCOUNT
, getAccount());
68 intent
.putExtra(FileDownloader
.EXTRA_FILE
, getFile());
73 Log_OC
.wtf(TAG
, "Unhandled conflict decision " + decision
);
76 i
.putExtra(FileUploader
.KEY_ACCOUNT
, getAccount());
77 i
.putExtra(FileUploader
.KEY_FILE
, getFile());
78 i
.putExtra(FileUploader
.KEY_UPLOAD_TYPE
, FileUploader
.UPLOAD_SINGLE_FILE
);
85 protected void onAccountSet(boolean stateWasRecovered
) {
86 super.onAccountSet(stateWasRecovered
);
87 if (getAccount() != null
) {
88 OCFile file
= getFile();
89 if (getFile() == null
) {
90 Log_OC
.e(TAG
, "No conflictive file received");
93 /// Check whether the 'main' OCFile handled by the Activity is contained in the current Account
94 file
= getStorageManager().getFileByPath(file
.getRemotePath()); // file = null if not in the current Account
97 ConflictsResolveDialog d
= ConflictsResolveDialog
.newInstance(file
.getRemotePath(), this);
101 // account was changed to a different one - just finish