Beispiel #1
0
  public void uploadFiles() {
    try {
      WebdavClient wdc =
          OwnCloudClientUtils.createOwnCloudClient(mAccount, getApplicationContext());

      // create last directory in path if necessary
      if (mCreateDir) {
        wdc.createDirectory(mUploadPath);
      }

      String[] local = new String[mStreamsToUpload.size()],
          remote = new String[mStreamsToUpload.size()];

      for (int i = 0; i < mStreamsToUpload.size(); ++i) {
        Uri uri = (Uri) mStreamsToUpload.get(i);
        if (uri.getScheme().equals("content")) {
          Cursor c =
              getContentResolver()
                  .query((Uri) mStreamsToUpload.get(i), CONTENT_PROJECTION, null, null, null);

          if (!c.moveToFirst()) continue;

          final String display_name = c.getString(c.getColumnIndex(Media.DISPLAY_NAME)),
              data = c.getString(c.getColumnIndex(Media.DATA));
          local[i] = data;
          remote[i] = mUploadPath + display_name;
        } else if (uri.getScheme().equals("file")) {
          final File file =
              new File(Uri.decode(uri.toString()).replace(uri.getScheme() + "://", ""));
          local[i] = file.getAbsolutePath();
          remote[i] = mUploadPath + file.getName();
        }
      }
      Intent intent = new Intent(getApplicationContext(), FileUploader.class);
      intent.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_MULTIPLE_FILES);
      intent.putExtra(FileUploader.KEY_LOCAL_FILE, local);
      intent.putExtra(FileUploader.KEY_REMOTE_FILE, remote);
      intent.putExtra(FileUploader.KEY_ACCOUNT, mAccount);
      startService(intent);
      finish();

    } catch (SecurityException e) {
      String message =
          String.format(
              getString(R.string.uploader_error_forbidden_content), getString(R.string.app_name));
      Toast.makeText(this, message, Toast.LENGTH_LONG).show();
    }
  }
  @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);
      }
    }
  }
 public void onDismiss(EditNameDialog dialog) {
   if (dialog.getResult()) {
     String newFilename = dialog.getNewFilename();
     Log.d(TAG, "name edit dialog dismissed with new name " + newFilename);
     mLastRemoteOperation =
         new RenameFileOperation(
             mFile,
             newFilename,
             new FileDataStorageManager(mAccount, getActivity().getContentResolver()));
     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);
   }
 }
    public void run() {
      AccountManager am = AccountManager.get(getActivity());
      Account account = AccountUtils.getCurrentOwnCloudAccount(getActivity());
      OwnCloudVersion ocv =
          new OwnCloudVersion(am.getUserData(account, AccountAuthenticator.KEY_OC_VERSION));
      String url =
          am.getUserData(account, AccountAuthenticator.KEY_OC_BASE_URL)
              + AccountUtils.getWebdavPath(ocv);

      Log.d("share", "sharing for version " + ocv.toString());

      if (ocv.compareTo(new OwnCloudVersion(0x040000)) >= 0) {
        String APPS_PATH = "/apps/files_sharing/";
        String SHARE_PATH = "ajax/share.php";

        String SHARED_PATH = "/apps/files_sharing/get.php?token=";

        final String WEBDAV_SCRIPT = "webdav.php";
        final String WEBDAV_FILES_LOCATION = "/files/";

        WebdavClient wc =
            OwnCloudClientUtils.createOwnCloudClient(
                account, getActivity().getApplicationContext());
        HttpConnectionManagerParams params = new HttpConnectionManagerParams();
        params.setMaxConnectionsPerHost(wc.getHostConfiguration(), 5);

        // wc.getParams().setParameter("http.protocol.single-cookie-header", true);
        // wc.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);

        PostMethod post =
            new PostMethod(
                am.getUserData(account, AccountAuthenticator.KEY_OC_BASE_URL)
                    + APPS_PATH
                    + SHARE_PATH);

        post.addRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
        post.addRequestHeader(
            "Referer", am.getUserData(account, AccountAuthenticator.KEY_OC_BASE_URL));
        List<NameValuePair> formparams = new ArrayList<NameValuePair>();
        Log.d("share", mPath + "");
        formparams.add(new BasicNameValuePair("sources", mPath));
        formparams.add(new BasicNameValuePair("uid_shared_with", "public"));
        formparams.add(new BasicNameValuePair("permissions", "0"));
        post.setRequestEntity(
            new StringRequestEntity(URLEncodedUtils.format(formparams, HTTP.UTF_8)));

        int status;
        try {
          PropFindMethod find = new PropFindMethod(url + "/");
          find.addRequestHeader(
              "Referer", am.getUserData(account, AccountAuthenticator.KEY_OC_BASE_URL));
          Log.d("sharer", "" + url + "/");

          for (org.apache.commons.httpclient.Header a : find.getRequestHeaders()) {
            Log.d("sharer-h", a.getName() + ":" + a.getValue());
          }

          int status2 = wc.executeMethod(find);

          Log.d("sharer", "propstatus " + status2);

          GetMethod get =
              new GetMethod(am.getUserData(account, AccountAuthenticator.KEY_OC_BASE_URL) + "/");
          get.addRequestHeader(
              "Referer", am.getUserData(account, AccountAuthenticator.KEY_OC_BASE_URL));

          status2 = wc.executeMethod(get);

          Log.d("sharer", "getstatus " + status2);
          Log.d("sharer", "" + get.getResponseBodyAsString());

          for (org.apache.commons.httpclient.Header a : get.getResponseHeaders()) {
            Log.d("sharer", a.getName() + ":" + a.getValue());
          }

          status = wc.executeMethod(post);
          for (org.apache.commons.httpclient.Header a : post.getRequestHeaders()) {
            Log.d("sharer-h", a.getName() + ":" + a.getValue());
          }
          for (org.apache.commons.httpclient.Header a : post.getResponseHeaders()) {
            Log.d("sharer", a.getName() + ":" + a.getValue());
          }
          String resp = post.getResponseBodyAsString();
          Log.d("share", "" + post.getURI().toString());
          Log.d("share", "returned status " + status);
          Log.d("share", " " + resp);

          if (status != HttpStatus.SC_OK
              || resp == null
              || resp.equals("")
              || resp.startsWith("false")) {
            return;
          }

          JSONObject jsonObject = new JSONObject(resp);
          String jsonStatus = jsonObject.getString("status");
          if (!jsonStatus.equals("success"))
            throw new Exception("Error while sharing file status != success");

          String token = jsonObject.getString("data");
          String uri =
              am.getUserData(account, AccountAuthenticator.KEY_OC_BASE_URL) + SHARED_PATH + token;
          Log.d("Actions:shareFile ok", "url: " + uri);

        } catch (Exception e) {
          e.printStackTrace();
        }

      } else if (ocv.compareTo(new OwnCloudVersion(0x030000)) >= 0) {

      }
    }
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.fdDownloadBtn:
        {
          // if (FileDownloader.isDownloading(mAccount, mFile.getRemotePath())) {
          FileDownloaderBinder downloaderBinder = mContainerActivity.getFileDownloaderBinder();
          FileUploaderBinder uploaderBinder = mContainerActivity.getFileUploaderBinder();
          if (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, mFile)) {
            downloaderBinder.cancel(mAccount, mFile);
            if (mFile.isDown()) {
              setButtonsForDown();
            } else {
              setButtonsForRemote();
            }

          } else if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, mFile)) {
            uploaderBinder.cancel(mAccount, mFile);
            if (!mFile.fileExists()) {
              // TODO make something better
              if (getActivity() instanceof FileDisplayActivity) {
                // double pane
                FragmentTransaction transaction =
                    getActivity().getSupportFragmentManager().beginTransaction();
                transaction.replace(
                    R.id.file_details_container,
                    new FileDetailFragment(null, null),
                    FTAG); // empty FileDetailFragment
                transaction.commit();
                mContainerActivity.onFileStateChanged();
              } else {
                getActivity().finish();
              }

            } else if (mFile.isDown()) {
              setButtonsForDown();
            } else {
              setButtonsForRemote();
            }

          } else {
            mLastRemoteOperation =
                new SynchronizeFileOperation(
                    mFile, null, mStorageManager, mAccount, true, false, getActivity());
            WebdavClient wc =
                OwnCloudClientUtils.createOwnCloudClient(
                    mAccount, getSherlockActivity().getApplicationContext());
            mLastRemoteOperation.execute(wc, this, mHandler);

            // update ui
            boolean inDisplayActivity = getActivity() instanceof FileDisplayActivity;
            getActivity()
                .showDialog(
                    (inDisplayActivity)
                        ? FileDisplayActivity.DIALOG_SHORT_WAIT
                        : FileDetailActivity.DIALOG_SHORT_WAIT);
            setButtonsForTransferring(); // disable button immediately, although the synchronization
                                         // does not result in a file transference
          }
          break;
        }
      case R.id.fdKeepInSync:
        {
          CheckBox cb = (CheckBox) getView().findViewById(R.id.fdKeepInSync);
          mFile.setKeepInSync(cb.isChecked());
          mStorageManager.saveFile(mFile);

          /// register the OCFile instance in the observer service to monitor local updates;
          /// if necessary, the file is download
          Intent intent =
              new Intent(getActivity().getApplicationContext(), FileObserverService.class);
          intent.putExtra(
              FileObserverService.KEY_FILE_CMD,
              (cb.isChecked()
                  ? FileObserverService.CMD_ADD_OBSERVED_FILE
                  : FileObserverService.CMD_DEL_OBSERVED_FILE));
          intent.putExtra(FileObserverService.KEY_CMD_ARG_FILE, mFile);
          intent.putExtra(FileObserverService.KEY_CMD_ARG_ACCOUNT, mAccount);
          Log.e(TAG, "starting observer service");
          getActivity().startService(intent);

          if (mFile.keepInSync()) {
            onClick(
                getView().findViewById(R.id.fdDownloadBtn)); // force an immediate synchronization
          }
          break;
        }
      case R.id.fdRenameBtn:
        {
          EditNameDialog dialog = EditNameDialog.newInstance(mFile.getFileName());
          dialog.setOnDismissListener(this);
          dialog.show(getFragmentManager(), "nameeditdialog");
          break;
        }
      case R.id.fdRemoveBtn:
        {
          ConfirmationDialogFragment confDialog =
              ConfirmationDialogFragment.newInstance(
                  R.string.confirmation_remove_alert,
                  new String[] {mFile.getFileName()},
                  mFile.isDown()
                      ? R.string.confirmation_remove_remote_and_local
                      : R.string.confirmation_remove_remote,
                  mFile.isDown() ? R.string.confirmation_remove_local : -1,
                  R.string.common_cancel);
          confDialog.setOnConfirmationListener(this);
          confDialog.show(getFragmentManager(), FTAG_CONFIRMATION);
          break;
        }
      case R.id.fdOpenBtn:
        {
          String storagePath = mFile.getStoragePath();
          String encodedStoragePath = WebdavUtils.encodePath(storagePath);
          try {
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setDataAndType(Uri.parse("file://" + encodedStoragePath), mFile.getMimetype());
            i.setFlags(
                Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
            startActivity(i);

          } catch (Throwable t) {
            Log.e(
                TAG,
                "Fail when trying to open with the mimeType provided from the ownCloud server: "
                    + mFile.getMimetype());
            boolean toastIt = true;
            String mimeType = "";
            try {
              Intent i = new Intent(Intent.ACTION_VIEW);
              mimeType =
                  MimeTypeMap.getSingleton()
                      .getMimeTypeFromExtension(
                          storagePath.substring(storagePath.lastIndexOf('.') + 1));
              if (mimeType != null && !mimeType.equals(mFile.getMimetype())) {
                i.setDataAndType(Uri.parse("file://" + encodedStoragePath), mimeType);
                i.setFlags(
                    Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
                startActivity(i);
                toastIt = false;
              }

            } catch (IndexOutOfBoundsException e) {
              Log.e(
                  TAG, "Trying to find out MIME type of a file without extension: " + storagePath);

            } catch (ActivityNotFoundException e) {
              Log.e(
                  TAG,
                  "No activity found to handle: "
                      + storagePath
                      + " with MIME type "
                      + mimeType
                      + " obtained from extension");

            } catch (Throwable th) {
              Log.e(TAG, "Unexpected problem when opening: " + storagePath, th);

            } finally {
              if (toastIt) {
                Toast.makeText(
                        getActivity(),
                        "There is no application to handle file " + mFile.getFileName(),
                        Toast.LENGTH_SHORT)
                    .show();
              }
            }
          }
          break;
        }
      default:
        Log.e(TAG, "Incorrect view clicked!");
    }

    /* else if (v.getId() == R.id.fdShareBtn) {
        Thread t = new Thread(new ShareRunnable(mFile.getRemotePath()));
        t.start();
    }*/
  }
Beispiel #6
0
    public void run() {
      WebdavClient wc =
          OwnCloudClientUtils.createOwnCloudClient(
              mAccount, getSherlockActivity().getApplicationContext());
      AccountManager am = AccountManager.get(getSherlockActivity());
      String baseUrl = am.getUserData(mAccount, AccountAuthenticator.KEY_OC_BASE_URL);
      OwnCloudVersion ocv =
          new OwnCloudVersion(am.getUserData(mAccount, AccountAuthenticator.KEY_OC_VERSION));
      String webdav_path = AccountUtils.getWebdavPath(ocv);
      Log.d("ASD", "" + baseUrl + webdav_path + WebdavUtils.encodePath(mOld.getRemotePath()));

      Log.e(
          "ASD",
          Uri.parse(baseUrl).getPath() == null
              ? ""
              : Uri.parse(baseUrl).getPath()
                  + webdav_path
                  + WebdavUtils.encodePath(mNew.getRemotePath()));
      LocalMoveMethod move =
          new LocalMoveMethod(
              baseUrl + webdav_path + WebdavUtils.encodePath(mOld.getRemotePath()),
              Uri.parse(baseUrl).getPath() == null
                  ? ""
                  : Uri.parse(baseUrl).getPath()
                      + webdav_path
                      + WebdavUtils.encodePath(mNew.getRemotePath()));

      boolean success = false;
      try {
        int status = wc.executeMethod(move);
        success = move.succeeded();
        move.getResponseBodyAsString(); // exhaust response, although not interesting
        Log.d(TAG, "Move returned status: " + status);

      } catch (HttpException e) {
        Log.e(
            TAG,
            "HTTP Exception renaming file " + mOld.getRemotePath() + " to " + mNew.getRemotePath(),
            e);

      } catch (IOException e) {
        Log.e(
            TAG,
            "I/O Exception renaming file " + mOld.getRemotePath() + " to " + mNew.getRemotePath(),
            e);

      } catch (Exception e) {
        Log.e(
            TAG,
            "Unexpected exception renaming file "
                + mOld.getRemotePath()
                + " to "
                + mNew.getRemotePath(),
            e);

      } finally {
        move.releaseConnection();
      }

      if (success) {
        FileDataStorageManager fdsm =
            new FileDataStorageManager(mAccount, getActivity().getContentResolver());
        fdsm.removeFile(mOld, false);
        fdsm.saveFile(mNew);
        mFile = mNew;
        mHandler.post(
            new Runnable() {
              @Override
              public void run() {
                boolean inDisplayActivity = getActivity() instanceof FileDisplayActivity;
                getActivity()
                    .dismissDialog(
                        (inDisplayActivity)
                            ? FileDisplayActivity.DIALOG_SHORT_WAIT
                            : FileDetailActivity.DIALOG_SHORT_WAIT);
                updateFileDetails(mFile, mAccount);
                mContainerActivity.onFileStateChanged();
              }
            });

      } else {
        mHandler.post(
            new Runnable() {
              @Override
              public void run() {
                // undo the local rename
                if (mNew.isDown()) {
                  File f = new File(mNew.getStoragePath());
                  if (!f.renameTo(new File(mOld.getStoragePath()))) {
                    // the local rename undoing failed; last chance: save the new local storage path
                    // in the old file
                    mFile.setStoragePath(mNew.getStoragePath());
                    FileDataStorageManager fdsm =
                        new FileDataStorageManager(mAccount, getActivity().getContentResolver());
                    fdsm.saveFile(mFile);
                  }
                }
                boolean inDisplayActivity = getActivity() instanceof FileDisplayActivity;
                getActivity()
                    .dismissDialog(
                        (inDisplayActivity)
                            ? FileDisplayActivity.DIALOG_SHORT_WAIT
                            : FileDetailActivity.DIALOG_SHORT_WAIT);
                try {
                  Toast msg =
                      Toast.makeText(
                          getActivity(), R.string.rename_server_fail_msg, Toast.LENGTH_LONG);
                  msg.show();

                } catch (NotFoundException e) {
                  e.printStackTrace();
                }
              }
            });
      }
    }
Beispiel #7
0
    public void run() {
      WebdavClient wc =
          OwnCloudClientUtils.createOwnCloudClient(
              mAccount, getSherlockActivity().getApplicationContext());
      AccountManager am = AccountManager.get(getSherlockActivity());
      String baseUrl = am.getUserData(mAccount, AccountAuthenticator.KEY_OC_BASE_URL);
      OwnCloudVersion ocv =
          new OwnCloudVersion(am.getUserData(mAccount, AccountAuthenticator.KEY_OC_VERSION));
      String webdav_path = AccountUtils.getWebdavPath(ocv);
      Log.d(
          "ASD",
          "" + baseUrl + webdav_path + WebdavUtils.encodePath(mFileToRemove.getRemotePath()));

      DeleteMethod delete =
          new DeleteMethod(
              baseUrl + webdav_path + WebdavUtils.encodePath(mFileToRemove.getRemotePath()));

      boolean success = false;
      int status = -1;
      try {
        status = wc.executeMethod(delete);
        success = (delete.succeeded());
        delete.getResponseBodyAsString(); // exhaust the response, although not interesting
        Log.d(TAG, "Delete: returned status " + status);

      } catch (HttpException e) {
        Log.e(TAG, "HTTP Exception removing file " + mFileToRemove.getRemotePath(), e);

      } catch (IOException e) {
        Log.e(TAG, "I/O Exception removing file " + mFileToRemove.getRemotePath(), e);

      } catch (Exception e) {
        Log.e(TAG, "Unexpected exception removing file " + mFileToRemove.getRemotePath(), e);

      } finally {
        delete.releaseConnection();
      }

      if (success) {
        FileDataStorageManager fdsm =
            new FileDataStorageManager(mAccount, getActivity().getContentResolver());
        fdsm.removeFile(mFileToRemove, true);
        mHandler.post(
            new Runnable() {
              @Override
              public void run() {
                boolean inDisplayActivity = getActivity() instanceof FileDisplayActivity;
                getActivity()
                    .dismissDialog(
                        (inDisplayActivity)
                            ? FileDisplayActivity.DIALOG_SHORT_WAIT
                            : FileDetailActivity.DIALOG_SHORT_WAIT);
                try {
                  Toast msg =
                      Toast.makeText(
                          getActivity().getApplicationContext(),
                          R.string.remove_success_msg,
                          Toast.LENGTH_LONG);
                  msg.show();
                  if (inDisplayActivity) {
                    // double pane
                    FragmentTransaction transaction =
                        getActivity().getSupportFragmentManager().beginTransaction();
                    transaction.replace(
                        R.id.file_details_container,
                        new FileDetailFragment(null, null)); // empty FileDetailFragment
                    transaction.commit();
                    mContainerActivity.onFileStateChanged();

                  } else {
                    getActivity().finish();
                  }

                } catch (NotFoundException e) {
                  e.printStackTrace();
                }
              }
            });

      } else {
        mHandler.post(
            new Runnable() {
              @Override
              public void run() {
                boolean inDisplayActivity = getActivity() instanceof FileDisplayActivity;
                getActivity()
                    .dismissDialog(
                        (inDisplayActivity)
                            ? FileDisplayActivity.DIALOG_SHORT_WAIT
                            : FileDetailActivity.DIALOG_SHORT_WAIT);
                try {
                  Toast msg =
                      Toast.makeText(getActivity(), R.string.remove_fail_msg, Toast.LENGTH_LONG);
                  msg.show();

                } catch (NotFoundException e) {
                  e.printStackTrace();
                }
              }
            });
      }
    }
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.fdDownloadBtn:
        {
          FileDownloaderBinder downloaderBinder = mContainerActivity.getFileDownloaderBinder();
          FileUploaderBinder uploaderBinder = mContainerActivity.getFileUploaderBinder();
          if (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, mFile)) {
            downloaderBinder.cancel(mAccount, mFile);
            if (mFile.isDown()) {
              setButtonsForDown();
            } else {
              setButtonsForRemote();
            }

          } else if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, mFile)) {
            uploaderBinder.cancel(mAccount, mFile);
            if (!mFile.fileExists()) {
              // TODO make something better
              if (getActivity() instanceof FileDisplayActivity) {
                // double pane
                FragmentTransaction transaction =
                    getActivity().getSupportFragmentManager().beginTransaction();
                transaction.replace(
                    R.id.file_details_container,
                    new FileDetailFragment(null, null),
                    FTAG); // empty FileDetailFragment
                transaction.commit();
                mContainerActivity.onFileStateChanged();
              } else {
                getActivity().finish();
              }

            } else if (mFile.isDown()) {
              setButtonsForDown();
            } else {
              setButtonsForRemote();
            }

          } else {
            mLastRemoteOperation =
                new SynchronizeFileOperation(
                    mFile, null, mStorageManager, mAccount, true, false, getActivity());
            WebdavClient wc =
                OwnCloudClientUtils.createOwnCloudClient(
                    mAccount, getSherlockActivity().getApplicationContext());
            mLastRemoteOperation.execute(wc, this, mHandler);

            // update ui
            boolean inDisplayActivity = getActivity() instanceof FileDisplayActivity;
            getActivity()
                .showDialog(
                    (inDisplayActivity)
                        ? FileDisplayActivity.DIALOG_SHORT_WAIT
                        : FileDetailActivity.DIALOG_SHORT_WAIT);
          }
          break;
        }
      case R.id.fdKeepInSync:
        {
          CheckBox cb = (CheckBox) getView().findViewById(R.id.fdKeepInSync);
          mFile.setKeepInSync(cb.isChecked());
          mStorageManager.saveFile(mFile);

          /// register the OCFile instance in the observer service to monitor local updates;
          /// if necessary, the file is download
          Intent intent =
              new Intent(getActivity().getApplicationContext(), FileObserverService.class);
          intent.putExtra(
              FileObserverService.KEY_FILE_CMD,
              (cb.isChecked()
                  ? FileObserverService.CMD_ADD_OBSERVED_FILE
                  : FileObserverService.CMD_DEL_OBSERVED_FILE));
          intent.putExtra(FileObserverService.KEY_CMD_ARG_FILE, mFile);
          intent.putExtra(FileObserverService.KEY_CMD_ARG_ACCOUNT, mAccount);
          getActivity().startService(intent);

          if (mFile.keepInSync()) {
            onClick(
                getView().findViewById(R.id.fdDownloadBtn)); // force an immediate synchronization
          }
          break;
        }
      case R.id.fdRenameBtn:
        {
          EditNameDialog dialog =
              EditNameDialog.newInstance(
                  getString(R.string.rename_dialog_title), mFile.getFileName(), this);
          dialog.show(getFragmentManager(), "nameeditdialog");
          break;
        }
      case R.id.fdRemoveBtn:
        {
          ConfirmationDialogFragment confDialog =
              ConfirmationDialogFragment.newInstance(
                  R.string.confirmation_remove_alert,
                  new String[] {mFile.getFileName()},
                  mFile.isDown()
                      ? R.string.confirmation_remove_remote_and_local
                      : R.string.confirmation_remove_remote,
                  mFile.isDown() ? R.string.confirmation_remove_local : -1,
                  R.string.common_cancel);
          confDialog.setOnConfirmationListener(this);
          confDialog.show(getFragmentManager(), FTAG_CONFIRMATION);
          break;
        }
      case R.id.fdOpenBtn:
        {
          openFile();
          break;
        }
      case R.id.fdShareBtn:
        {;
          break;
        }
      default:
        Log.e(TAG, "Incorrect view clicked!");
    }

    /* else if (v.getId() == R.id.fdShareBtn) {
        Thread t = new Thread(new ShareRunnable(mFile.getRemotePath()));
        t.start();
    }*/
  }