1 /* ownCloud Android client application
3 * @author Bartek Przybylski
4 * @author David A. Velasco
5 * Copyright (C) 2012 Bartek Przybylski
6 * Copyright (C) 2012-2013 ownCloud Inc.
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 package com
.owncloud
.android
.ui
.activity
;
24 import com
.actionbarsherlock
.app
.ActionBar
;
25 import com
.owncloud
.android
.datamodel
.OCFile
;
26 import com
.owncloud
.android
.files
.services
.FileUploader
;
27 import com
.owncloud
.android
.lib
.common
.utils
.Log_OC
;
28 import com
.owncloud
.android
.ui
.dialog
.ConflictsResolveDialog
;
29 import com
.owncloud
.android
.ui
.dialog
.ConflictsResolveDialog
.Decision
;
30 import com
.owncloud
.android
.ui
.dialog
.ConflictsResolveDialog
.OnConflictDecisionMadeListener
;
31 import com
.owncloud
.android
.utils
.DisplayUtils
;
33 import android
.content
.Intent
;
34 import android
.os
.Bundle
;
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
);
47 ActionBar actionBar
= getSupportActionBar();
48 actionBar
.setIcon(DisplayUtils
.getSeasonalIconId());
52 public void conflictDecisionMade(Decision decision
) {
53 Intent i
= new Intent(getApplicationContext(), FileUploader
.class);
60 i
.putExtra(FileUploader
.KEY_FORCE_OVERWRITE
, true
);
63 i
.putExtra(FileUploader
.KEY_LOCAL_BEHAVIOUR
, FileUploader
.LOCAL_BEHAVIOUR_MOVE
);
66 Log_OC
.wtf(TAG
, "Unhandled conflict decision " + decision
);
69 i
.putExtra(FileUploader
.KEY_ACCOUNT
, getAccount());
70 i
.putExtra(FileUploader
.KEY_FILE
, getFile());
71 i
.putExtra(FileUploader
.KEY_UPLOAD_TYPE
, FileUploader
.UPLOAD_SINGLE_FILE
);
78 protected void onAccountSet(boolean stateWasRecovered
) {
79 super.onAccountSet(stateWasRecovered
);
80 if (getAccount() != null
) {
81 OCFile file
= getFile();
82 if (getFile() == null
) {
83 Log_OC
.e(TAG
, "No conflictive file received");
86 /// Check whether the 'main' OCFile handled by the Activity is contained in the current Account
87 file
= getStorageManager().getFileByPath(file
.getRemotePath()); // file = null if not in the current Account
90 ConflictsResolveDialog d
= ConflictsResolveDialog
.newInstance(file
.getRemotePath(), this);
94 // account was changed to a different one - just finish