UploadPathActivity.java 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. package com.owncloud.android.ui.activity;
  20. import android.accounts.Account;
  21. import android.os.Bundle;
  22. import android.view.View.OnClickListener;
  23. import com.owncloud.android.datamodel.OCFile;
  24. import com.owncloud.android.ui.fragment.FileFragment;
  25. import com.owncloud.android.ui.fragment.OCFileListFragment;
  26. public class UploadPathActivity extends FolderPickerActivity implements FileFragment.ContainerActivity,
  27. OnClickListener, OnEnforceableRefreshListener {
  28. public static final String KEY_INSTANT_UPLOAD_PATH = "INSTANT_UPLOAD_PATH";
  29. @Override
  30. protected void onCreate(Bundle savedInstanceState) {
  31. super.onCreate(savedInstanceState);
  32. String instantUploadPath = getIntent().getStringExtra(KEY_INSTANT_UPLOAD_PATH);
  33. // The caller activity (Preferences) is not a FileActivity, so it has no OCFile, only a path.
  34. OCFile folder = new OCFile(instantUploadPath);
  35. setFile(folder);
  36. }
  37. /**
  38. * Called when the ownCloud {@link Account} associated to the Activity was
  39. * just updated.
  40. */
  41. @Override
  42. protected void onAccountSet(boolean stateWasRecovered) {
  43. super.onAccountSet(stateWasRecovered);
  44. if (getAccount() != null) {
  45. updateFileFromDB();
  46. OCFile folder = getFile();
  47. if (folder == null || !folder.isFolder()) {
  48. // fall back to root folder
  49. setFile(getStorageManager().getFileByPath(OCFile.ROOT_PATH));
  50. folder = getFile();
  51. }
  52. onBrowsedDownTo(folder);
  53. if (!stateWasRecovered) {
  54. OCFileListFragment listOfFolders = getListOfFilesFragment();
  55. // TODO Enable when "On Device" is recovered ?
  56. listOfFolders.listDirectory(folder/*, false*/);
  57. startSyncFolderOperation(folder, false);
  58. }
  59. updateNavigationElementsInActionBar();
  60. }
  61. }
  62. }