Пример #1
0
  public void onDismiss(EditNameFragment dialog) {
    if (dialog instanceof EditNameFragment) {
      if (((EditNameFragment) dialog).getResult()) {
        String newFilename = ((EditNameFragment) dialog).getNewFilename();
        Log.d(TAG, "name edit dialog dismissed with new name " + newFilename);
        if (!newFilename.equals(mFile.getFileName())) {
          FileDataStorageManager fdsm =
              new FileDataStorageManager(mAccount, getActivity().getContentResolver());
          if (fdsm.getFileById(mFile.getFileId()) != null) {
            OCFile newFile =
                new OCFile(fdsm.getFileById(mFile.getParentId()).getRemotePath() + newFilename);
            newFile.setCreationTimestamp(mFile.getCreationTimestamp());
            newFile.setFileId(mFile.getFileId());
            newFile.setFileLength(mFile.getFileLength());
            newFile.setKeepInSync(mFile.keepInSync());
            newFile.setLastSyncDate(mFile.getLastSyncDate());
            newFile.setMimetype(mFile.getMimetype());
            newFile.setModificationTimestamp(mFile.getModificationTimestamp());
            newFile.setParentId(mFile.getParentId());
            boolean localRenameFails = false;
            if (mFile.isDown()) {
              File f = new File(mFile.getStoragePath());
              Log.e(TAG, f.getAbsolutePath());
              localRenameFails =
                  !(f.renameTo(new File(f.getParent() + File.separator + newFilename)));
              Log.e(TAG, f.getParent() + File.separator + newFilename);
              newFile.setStoragePath(f.getParent() + File.separator + newFilename);
            }

            if (localRenameFails) {
              Toast msg =
                  Toast.makeText(getActivity(), R.string.rename_local_fail_msg, Toast.LENGTH_LONG);
              msg.show();

            } else {
              new Thread(new RenameRunnable(mFile, newFile, mAccount, new Handler())).start();
              boolean inDisplayActivity = getActivity() instanceof FileDisplayActivity;
              getActivity()
                  .showDialog(
                      (inDisplayActivity)
                          ? FileDisplayActivity.DIALOG_SHORT_WAIT
                          : FileDetailActivity.DIALOG_SHORT_WAIT);
            }
          }
        }
      }
    } else {
      Log.e(
          TAG,
          "Unknown dialog instance passed to onDismissDalog: "
              + dialog.getClass().getCanonicalName());
    }
  }
Пример #2
0
  /**
   * Saves a OC File after a successful upload.
   *
   * <p>A PROPFIND is necessary to keep the props in the local database synchronized with the
   * server, specially the modification time and Etag (where available)
   *
   * <p>TODO refactor this ugly thing
   */
  private void saveUploadedFile() {
    OCFile file = mCurrentUpload.getFile();
    if (file.fileExists()) {
      file = mStorageManager.getFileById(file.getFileId());
    }
    long syncDate = System.currentTimeMillis();
    file.setLastSyncDateForData(syncDate);

    // new PROPFIND to keep data consistent with server
    // in theory, should return the same we already have
    ReadRemoteFileOperation operation = new ReadRemoteFileOperation(mCurrentUpload.getRemotePath());
    RemoteOperationResult result = operation.execute(mUploadClient);
    if (result.isSuccess()) {
      updateOCFile(file, (RemoteFile) result.getData().get(0));
      file.setLastSyncDateForProperties(syncDate);
    }

    // / maybe this would be better as part of UploadFileOperation... or
    // maybe all this method
    if (mCurrentUpload.wasRenamed()) {
      OCFile oldFile = mCurrentUpload.getOldFile();
      if (oldFile.fileExists()) {
        oldFile.setStoragePath(null);
        mStorageManager.saveFile(oldFile);
      } // else: it was just an automatic renaming due to a name
      // coincidence; nothing else is needed, the storagePath is right
      // in the instance returned by mCurrentUpload.getFile()
    }

    mStorageManager.saveFile(file);
  }
Пример #3
0
 @Override
 public void onConfirmation(String callerTag) {
   if (callerTag.equals(FTAG_CONFIRMATION)) {
     FileDataStorageManager fdsm =
         new FileDataStorageManager(mAccount, getActivity().getContentResolver());
     if (fdsm.getFileById(mFile.getFileId()) != null) {
       new Thread(new RemoveRunnable(mFile, mAccount, new Handler())).start();
       boolean inDisplayActivity = getActivity() instanceof FileDisplayActivity;
       getActivity()
           .showDialog(
               (inDisplayActivity)
                   ? FileDisplayActivity.DIALOG_SHORT_WAIT
                   : FileDetailActivity.DIALOG_SHORT_WAIT);
     }
   }
 }
Пример #4
0
  @Override
  public void onConfirmation(String callerTag) {
    if (callerTag.equals(FTAG_CONFIRMATION)) {
      if (mStorageManager.getFileById(mFile.getFileId()) != null) {
        mLastRemoteOperation = new RemoveFileOperation(mFile, true, mStorageManager);
        WebdavClient wc =
            OwnCloudClientUtils.createOwnCloudClient(
                mAccount, getSherlockActivity().getApplicationContext());
        mLastRemoteOperation.execute(wc, this, mHandler);

        boolean inDisplayActivity = getActivity() instanceof FileDisplayActivity;
        getActivity()
            .showDialog(
                (inDisplayActivity)
                    ? FileDisplayActivity.DIALOG_SHORT_WAIT
                    : FileDetailActivity.DIALOG_SHORT_WAIT);
      }
    }
  }