Disable On Device option in Navigation Drawer
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / activity / UploadPathActivity.java
1 /**
2 * ownCloud Android client application
3 *
4 * Copyright (C) 2015 ownCloud Inc.
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2,
8 * as published by the Free Software Foundation.
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 android.accounts.Account;
23 import android.os.Bundle;
24 import android.view.View.OnClickListener;
25
26 import com.owncloud.android.datamodel.OCFile;
27 import com.owncloud.android.ui.fragment.FileFragment;
28 import com.owncloud.android.ui.fragment.OCFileListFragment;
29
30 public class UploadPathActivity extends FolderPickerActivity implements FileFragment.ContainerActivity,
31 OnClickListener, OnEnforceableRefreshListener {
32
33 public static final String KEY_INSTANT_UPLOAD_PATH = "INSTANT_UPLOAD_PATH";
34
35
36 @Override
37 protected void onCreate(Bundle savedInstanceState) {
38 super.onCreate(savedInstanceState);
39
40 String instantUploadPath = getIntent().getStringExtra(KEY_INSTANT_UPLOAD_PATH);
41
42 // The caller activity (Preferences) is not a FileActivity, so it has no OCFile, only a path.
43 OCFile folder = new OCFile(instantUploadPath);
44
45 setFile(folder);
46 }
47
48 /**
49 * Called when the ownCloud {@link Account} associated to the Activity was
50 * just updated.
51 */
52 @Override
53 protected void onAccountSet(boolean stateWasRecovered) {
54 super.onAccountSet(stateWasRecovered);
55 if (getAccount() != null) {
56
57 updateFileFromDB();
58
59 OCFile folder = getFile();
60 if (folder == null || !folder.isFolder()) {
61 // fall back to root folder
62 setFile(getStorageManager().getFileByPath(OCFile.ROOT_PATH));
63 folder = getFile();
64 }
65
66 onBrowsedDownTo(folder);
67
68 if (!stateWasRecovered) {
69 OCFileListFragment listOfFolders = getListOfFilesFragment();
70 // TODO Enable when "On Device" is recovered ?
71 listOfFolders.listDirectory(folder/*, false*/);
72
73 startSyncFolderOperation(folder, false);
74 }
75
76 updateNavigationElementsInActionBar();
77 }
78 }
79 }