Merge branch 'develop' into share_password_support
authormasensio <masensio@solidgear.es>
Fri, 6 Mar 2015 09:19:06 +0000 (10:19 +0100)
committermasensio <masensio@solidgear.es>
Fri, 6 Mar 2015 09:19:06 +0000 (10:19 +0100)
1  2 
src/com/owncloud/android/operations/CreateShareOperation.java
src/com/owncloud/android/services/OperationsService.java
src/com/owncloud/android/ui/activity/FileActivity.java

@@@ -1,5 -1,8 +1,8 @@@
- /* ownCloud Android client application
-  *   Copyright (C) 2014 ownCloud Inc.
+ /**
+  *   ownCloud Android client application
+  *
+  *   @author masensio
+  *   Copyright (C) 2015 ownCloud Inc.
   *
   *   This program is free software: you can redistribute it and/or modify
   *   it under the terms of the GNU General Public License version 2,
@@@ -19,9 -22,6 +22,6 @@@ package com.owncloud.android.operations
  
  /**
   * Creates a new share from a given file
-  * 
-  * @author masensio
-  *
   */
  
  import android.content.Context;
@@@ -98,8 -98,7 +98,8 @@@ public class CreateShareOperation exten
          RemoteOperationResult result = ((GetRemoteSharesForFileOperation)operation).execute(client);
  
          if (!result.isSuccess() || result.getData().size() <= 0) {
 -            operation = new CreateRemoteShareOperation(mPath, mShareType, mShareWith, mPublicUpload, mPassword, mPermissions);
 +            operation = new CreateRemoteShareOperation(mPath, mShareType, mShareWith, mPublicUpload,
 +                    mPassword, mPermissions);
              result = ((CreateRemoteShareOperation)operation).execute(client);
          }
          
@@@ -1,5 -1,7 +1,7 @@@
- /* ownCloud Android client application
-  *   Copyright (C) 2012-2014 ownCloud Inc.
+ /**
+  *   ownCloud Android client application
+  *
+  *   Copyright (C) 2015 ownCloud Inc.
   *
   *   This program is free software: you can redistribute it and/or modify
   *   it under the terms of the GNU General Public License version 2,
@@@ -525,8 -527,7 +527,8 @@@ public class OperationsService extends 
                      String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH);
                      Intent sendIntent = operationIntent.getParcelableExtra(EXTRA_SEND_INTENT);
                      if (remotePath.length() > 0) {
 -                        operation = new CreateShareOperation(OperationsService.this, remotePath, ShareType.PUBLIC_LINK,
 +                        operation = new CreateShareOperation(OperationsService.this, remotePath,
 +                                ShareType.PUBLIC_LINK,
                                  "", false, "", 1, sendIntent);
                      }
                      
@@@ -1,6 -1,9 +1,9 @@@
- /* ownCloud Android client application
+ /**
+  *   ownCloud Android client application
+  *
+  *   @author David A. Velasco
   *   Copyright (C) 2011  Bartek Przybylski
-  *   Copyright (C) 2012-2015 ownCloud Inc.
+  *   Copyright (C) 2015 ownCloud Inc.
   *
   *   This program is free software: you can redistribute it and/or modify
   *   it under the terms of the GNU General Public License version 2,
@@@ -58,16 -61,12 +61,14 @@@ import com.owncloud.android.operations.
  import com.owncloud.android.operations.UnshareLinkOperation;
  import com.owncloud.android.services.OperationsService;
  import com.owncloud.android.services.OperationsService.OperationsServiceBinder;
 +import com.owncloud.android.ui.dialog.CreateFolderDialogFragment;
  import com.owncloud.android.ui.dialog.LoadingDialog;
 +import com.owncloud.android.ui.dialog.SharePasswordDialogFragment;
  import com.owncloud.android.utils.ErrorMessageAdapter;
  
  
  /**
   * Activity with common behaviour for activities handling {@link OCFile}s in ownCloud {@link Account}s .
-  * 
-  * @author David A. Velasco
   */
  public class FileActivity extends SherlockFragmentActivity
          implements OnRemoteOperationListener, ComponentsGetter {
@@@ -81,7 -80,6 +82,7 @@@
      
      private static final String DIALOG_WAIT_TAG = "DIALOG_WAIT";
      private static final String KEY_WAITING_FOR_OP_ID = "WAITING_FOR_OP_ID";
 +    private static final String DIALOG_SHARE_PASSWORD = "DIALOG_SHARE_PASSWORD";
      
      protected static final long DELAY_TO_REQUEST_OPERATION_ON_ACTIVITY_RESULTS = 200;
      
       * a new ownCloud {@link Account} finished, successfully or not.
       * 
       * At this moment, only called after the creation of the first account.
-      * 
-      * @author David A. Velasco
       */
      public class AccountCreationCallback implements AccountManagerCallback<Bundle> {
  
              Intent sendIntent = operation.getSendIntent();
              startActivity(sendIntent);
              
 -        } else { 
 -            Toast t = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()), 
 -                    Toast.LENGTH_LONG);
 -            t.show();
 +        } else {
 +            // TODO Detect Failure (403) --> needs Password
 +            if (result.getCode() == ResultCode.SHARE_FORBIDDEN) {
 +                SharePasswordDialogFragment dialog =
 +                        SharePasswordDialogFragment.newInstance(getFile());
 +                dialog.show(getSupportFragmentManager(), DIALOG_SHARE_PASSWORD);
 +            } else {
 +                Toast t = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
 +                        Toast.LENGTH_LONG);
 +                t.show();
 +            }
          } 
      }