Exemplo n.º 1
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);

    if (savedInstanceState != null) {
      mFile = savedInstanceState.getParcelable(FileDetailFragment.EXTRA_FILE);
      mAccount = savedInstanceState.getParcelable(FileDetailFragment.EXTRA_ACCOUNT);
    }

    View view = null;
    view = inflater.inflate(mLayout, container, false);
    mView = view;

    if (mLayout == R.layout.file_details_fragment) {
      mView.findViewById(R.id.fdKeepInSync).setOnClickListener(this);
      mView.findViewById(R.id.fdRenameBtn).setOnClickListener(this);
      mView.findViewById(R.id.fdDownloadBtn).setOnClickListener(this);
      mView.findViewById(R.id.fdOpenBtn).setOnClickListener(this);
      mView.findViewById(R.id.fdRemoveBtn).setOnClickListener(this);
      // mView.findViewById(R.id.fdShareBtn).setOnClickListener(this);
      mPreview = (ImageView) mView.findViewById(R.id.fdPreview);
    }

    updateFileDetails();
    return view;
  }
Exemplo n.º 2
0
  private void onRenameFileOperationFinish(
      RenameFileOperation operation, RemoteOperationResult result) {
    boolean inDisplayActivity = getActivity() instanceof FileDisplayActivity;
    getActivity()
        .dismissDialog(
            (inDisplayActivity)
                ? FileDisplayActivity.DIALOG_SHORT_WAIT
                : FileDetailActivity.DIALOG_SHORT_WAIT);

    if (result.isSuccess()) {
      updateFileDetails(((RenameFileOperation) operation).getFile(), mAccount);
      mContainerActivity.onFileStateChanged();

    } else {
      if (result.getCode().equals(ResultCode.INVALID_LOCAL_FILE_NAME)) {
        Toast msg =
            Toast.makeText(getActivity(), R.string.rename_local_fail_msg, Toast.LENGTH_LONG);
        msg.show();
        // TODO throw again the new rename dialog
      } else {
        Toast msg =
            Toast.makeText(getActivity(), R.string.rename_server_fail_msg, Toast.LENGTH_LONG);
        msg.show();
        if (result.isSslRecoverableException()) {
          // TODO show the SSL warning dialog
        }
      }
    }
  }
Exemplo n.º 3
0
 @Override
 public void onNeutral(String callerTag) {
   File f = null;
   if (mFile.isDown() && (f = new File(mFile.getStoragePath())).exists()) {
     f.delete();
     mFile.setStoragePath(null);
     mStorageManager.saveFile(mFile);
     updateFileDetails(mFile, mAccount);
   }
 }
Exemplo n.º 4
0
 /**
  * Use this method to signal this Activity that it shall update its view.
  *
  * @param file : An {@link OCFile}
  */
 public void updateFileDetails(OCFile file, Account ocAccount) {
   mFile = file;
   if (ocAccount != null
       && (mStorageManager == null || (mAccount != null && !mAccount.equals(ocAccount)))) {
     mStorageManager =
         new FileDataStorageManager(
             ocAccount, getActivity().getApplicationContext().getContentResolver());
   }
   mAccount = ocAccount;
   updateFileDetails();
 }
Exemplo n.º 5
0
  @Override
  protected void onResume() {

    super.onResume();
    if (!mConfigurationChangedToLandscape) {
      FileDetailFragment fragment =
          (FileDetailFragment)
              getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG);
      fragment.updateFileDetails(false);
    }
  }
Exemplo n.º 6
0
 @Override
 public void onNeutral(String callerTag) {
   FileDataStorageManager fdsm =
       new FileDataStorageManager(mAccount, getActivity().getContentResolver());
   File f = null;
   if (mFile.isDown() && (f = new File(mFile.getStoragePath())).exists()) {
     f.delete();
     mFile.setStoragePath(null);
     fdsm.saveFile(mFile);
     updateFileDetails(mFile, mAccount);
   }
 }
Exemplo n.º 7
0
 @Override
 public void onServiceConnected(ComponentName component, IBinder service) {
   if (component.equals(new ComponentName(FileDetailActivity.this, FileDownloader.class))) {
     Log.d(TAG, "Download service connected");
     mDownloaderBinder = (FileDownloaderBinder) service;
   } else if (component.equals(new ComponentName(FileDetailActivity.this, FileUploader.class))) {
     Log.d(TAG, "Upload service connected");
     mUploaderBinder = (FileUploaderBinder) service;
   } else {
     return;
   }
   FileDetailFragment fragment =
       (FileDetailFragment)
           getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG);
   if (fragment != null)
     fragment.updateFileDetails(
         false); // let the fragment gets the mDownloadBinder through getDownloadBinder() (see
                 // FileDetailFragment#updateFileDetais())
 }
Exemplo n.º 8
0
 /**
  * Use this method to signal this Activity that it shall update its view.
  *
  * @param file : An {@link OCFile}
  */
 public void updateFileDetails(OCFile file, Account ocAccount) {
   mFile = file;
   mAccount = ocAccount;
   updateFileDetails();
 }