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 com
.actionbarsherlock
.app
.ActionBar
;
26 import com
.owncloud
.android
.datamodel
.OCFile
;
27 import com
.owncloud
.android
.files
.services
.FileUploader
;
28 import com
.owncloud
.android
.lib
.common
.utils
.Log_OC
;
29 import com
.owncloud
.android
.ui
.dialog
.ConflictsResolveDialog
;
30 import com
.owncloud
.android
.ui
.dialog
.ConflictsResolveDialog
.Decision
;
31 import com
.owncloud
.android
.ui
.dialog
.ConflictsResolveDialog
.OnConflictDecisionMadeListener
;
32 import com
.owncloud
.android
.utils
.DisplayUtils
;
34 import android
.content
.Intent
;
35 import android
.os
.Bundle
;
38 * Wrapper activity which will be launched if keep-in-sync file will be modified by external
41 public class ConflictsResolveActivity
extends FileActivity
implements OnConflictDecisionMadeListener
{
43 private String TAG
= ConflictsResolveActivity
.class.getSimpleName();
46 protected void onCreate(Bundle savedInstanceState
) {
47 super.onCreate(savedInstanceState
);
48 ActionBar actionBar
= getSupportActionBar();
49 actionBar
.setIcon(DisplayUtils
.getSeasonalIconId());
53 public void conflictDecisionMade(Decision decision
) {
54 Intent i
= new Intent(getApplicationContext(), FileUploader
.class);
61 i
.putExtra(FileUploader
.KEY_FORCE_OVERWRITE
, true
);
64 i
.putExtra(FileUploader
.KEY_LOCAL_BEHAVIOUR
, FileUploader
.LOCAL_BEHAVIOUR_MOVE
);
67 Log_OC
.wtf(TAG
, "Unhandled conflict decision " + decision
);
70 i
.putExtra(FileUploader
.KEY_ACCOUNT
, getAccount());
71 i
.putExtra(FileUploader
.KEY_FILE
, getFile());
72 i
.putExtra(FileUploader
.KEY_UPLOAD_TYPE
, FileUploader
.UPLOAD_SINGLE_FILE
);
79 protected void onAccountSet(boolean stateWasRecovered
) {
80 super.onAccountSet(stateWasRecovered
);
81 if (getAccount() != null
) {
82 OCFile file
= getFile();
83 if (getFile() == null
) {
84 Log_OC
.e(TAG
, "No conflictive file received");
87 /// Check whether the 'main' OCFile handled by the Activity is contained in the current Account
88 file
= getStorageManager().getFileByPath(file
.getRemotePath()); // file = null if not in the current Account
91 ConflictsResolveDialog d
= ConflictsResolveDialog
.newInstance(file
.getRemotePath(), this);
95 // account was changed to a different one - just finish