Exemple #1
0
  private void onCreateShareViaLinkOperationFinish(
      CreateShareViaLinkOperation operation, RemoteOperationResult result) {
    if (result.isSuccess()) {
      updateFileFromDB();

      Intent sendIntent = operation.getSendIntentWithSubject(this);
      if (sendIntent != null) {
        startActivity(sendIntent);
      }

    } else {
      // Detect Failure (403) --> needs Password
      if (result.getCode() == ResultCode.SHARE_FORBIDDEN) {
        String password = operation.getPassword();
        if ((password == null || password.length() == 0)
            && getCapabilities().getFilesSharingPublicEnabled().isUnknown()) {
          // Was tried without password, but not sure that it's optional. Try with password.
          // Try with password before giving up.
          // See also ShareFileFragment#OnShareViaLinkListener
          SharePasswordDialogFragment dialog =
              SharePasswordDialogFragment.newInstance(new OCFile(operation.getPath()), true);
          dialog.show(getSupportFragmentManager(), DIALOG_SHARE_PASSWORD);
        } else {
          Toast t =
              Toast.makeText(
                  this,
                  ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
                  Toast.LENGTH_LONG);
          t.show();
        }
      } else {
        Toast t =
            Toast.makeText(
                this,
                ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
                Toast.LENGTH_LONG);
        t.show();
      }
    }
  }
Exemple #2
0
  private void onSynchronizeFileOperationFinish(
      SynchronizeFileOperation operation, RemoteOperationResult result) {
    OCFile syncedFile = operation.getLocalFile();
    if (!result.isSuccess()) {
      if (result.getCode() == ResultCode.SYNC_CONFLICT) {
        Intent i = new Intent(this, ConflictsResolveActivity.class);
        i.putExtra(ConflictsResolveActivity.EXTRA_FILE, syncedFile);
        i.putExtra(ConflictsResolveActivity.EXTRA_ACCOUNT, getAccount());
        startActivity(i);
      }

    } else {
      if (!operation.transferWasRequested()) {
        Toast msg =
            Toast.makeText(
                this,
                ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
                Toast.LENGTH_LONG);
        msg.show();
      }
      invalidateOptionsMenu();
    }
  }
Exemple #3
0
  /**
   * @param operation Removal operation performed.
   * @param result Result of the removal.
   */
  @Override
  public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
    Log_OC.d(
        TAG,
        "Received result of operation in FileActivity - common behaviour for all the "
            + "FileActivities ");

    mFileOperationsHelper.setOpIdWaitingFor(Long.MAX_VALUE);

    dismissLoadingDialog();

    if (!result.isSuccess()
        && (result.getCode() == ResultCode.UNAUTHORIZED
            || result.isIdPRedirection()
            || (result.isException() && result.getException() instanceof AuthenticatorException))) {

      requestCredentialsUpdate();

      if (result.getCode() == ResultCode.UNAUTHORIZED) {
        dismissLoadingDialog();
        Toast t =
            Toast.makeText(
                this,
                ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
                Toast.LENGTH_LONG);
        t.show();
      }

    } else if (operation == null
        || operation instanceof CreateShareWithShareeOperation
        || operation instanceof UnshareOperation
        || operation instanceof SynchronizeFolderOperation
        || operation instanceof UpdateShareViaLinkOperation) {
      if (result.isSuccess()) {
        updateFileFromDB();

      } else if (result.getCode() != ResultCode.CANCELLED) {
        Toast t =
            Toast.makeText(
                this,
                ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
                Toast.LENGTH_LONG);
        t.show();
      }

    } else if (operation instanceof CreateShareViaLinkOperation) {
      onCreateShareViaLinkOperationFinish((CreateShareViaLinkOperation) operation, result);

    } else if (operation instanceof SynchronizeFileOperation) {
      onSynchronizeFileOperationFinish((SynchronizeFileOperation) operation, result);

    } else if (operation instanceof GetSharesForFileOperation) {
      if (result.isSuccess() || result.getCode() == ResultCode.SHARE_NOT_FOUND) {
        updateFileFromDB();

      } else {
        Toast t =
            Toast.makeText(
                this,
                ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
                Toast.LENGTH_LONG);
        t.show();
      }
    }
  }