UploadPathActivity.java 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* ownCloud Android client application
  2. * Copyright (C) 2012-2014 ownCloud Inc.
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2,
  6. * as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. *
  16. */
  17. package com.owncloud.android.ui.activity;
  18. import android.accounts.Account;
  19. import android.os.Bundle;
  20. import android.view.View.OnClickListener;
  21. import com.owncloud.android.datamodel.OCFile;
  22. import com.owncloud.android.ui.fragment.FileFragment;
  23. import com.owncloud.android.ui.fragment.OCFileListFragment;
  24. public class UploadPathActivity extends FolderPickerActivity implements FileFragment.ContainerActivity,
  25. OnClickListener, OnEnforceableRefreshListener {
  26. public static final String KEY_INSTANT_UPLOAD_PATH = "INSTANT_UPLOAD_PATH";
  27. @Override
  28. protected void onCreate(Bundle savedInstanceState) {
  29. super.onCreate(savedInstanceState);
  30. String instantUploadPath = getIntent().getStringExtra(KEY_INSTANT_UPLOAD_PATH);
  31. // The caller activity (Preferences) is not a FileActivity, so it has no OCFile, only a path.
  32. OCFile folder = new OCFile(instantUploadPath);
  33. setFile(folder);
  34. }
  35. /**
  36. * Called when the ownCloud {@link Account} associated to the Activity was
  37. * just updated.
  38. */
  39. @Override
  40. protected void onAccountSet(boolean stateWasRecovered) {
  41. super.onAccountSet(stateWasRecovered);
  42. if (getAccount() != null) {
  43. updateFileFromDB();
  44. OCFile folder = getFile();
  45. if (folder == null || !folder.isFolder()) {
  46. // fall back to root folder
  47. setFile(getStorageManager().getFileByPath(OCFile.ROOT_PATH));
  48. folder = getFile();
  49. }
  50. onBrowsedDownTo(folder);
  51. if (!stateWasRecovered) {
  52. OCFileListFragment listOfFolders = getListOfFilesFragment();
  53. listOfFolders.listDirectory(folder);
  54. startSyncFolderOperation(folder, false);
  55. }
  56. updateNavigationElementsInActionBar();
  57. }
  58. }
  59. }