Merge branch 'develop' into create_folder_during_upload_pr_701_with_develop
authormasensio <masensio@solidgear.es>
Mon, 16 Mar 2015 10:15:27 +0000 (11:15 +0100)
committermasensio <masensio@solidgear.es>
Mon, 16 Mar 2015 10:15:27 +0000 (11:15 +0100)
1  2 
res/layout/uploader_layout.xml
res/values/strings.xml
src/com/owncloud/android/ui/activity/Uploader.java

@@@ -3,7 -3,7 +3,7 @@@
    ownCloud Android client application
  
    Copyright (C) 2012  Bartek Przybylski
-   Copyright (C) 2012-2013 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,
                        android:layout_height="fill_parent" android:divider="@drawable/uploader_list_separator"
                        android:dividerHeight="1dip"></ListView>
        </FrameLayout>
 -      <LinearLayout android:id="@+id/linearLayout1"
 -              android:layout_width="fill_parent" android:layout_alignParentBottom="true" android:layout_height="wrap_content" android:orientation="vertical">
 -              <Button android:layout_gravity="bottom" android:layout_height="wrap_content"
 -                      android:layout_width="fill_parent" android:id="@+id/uploader_choose_folder"
 -                      android:text="@string/uploader_btn_upload_text"/>
 +
 +      <LinearLayout
 +          android:id="@+id/linearLayout1"
 +          android:layout_width="fill_parent"
 +          android:layout_height="wrap_content"
 +          android:layout_alignParentBottom="true"
 +          android:orientation="horizontal" >
 +
 +              <Button
 +                  android:id="@+id/uploader_new_folder"
 +                  android:layout_width="fill_parent"
 +                  android:layout_height="wrap_content"
 +                  android:layout_gravity="bottom"
 +                  android:layout_weight="1"
 +                  android:text="@string/uploader_btn_new_folder_text" />
 +              
 +              <Button
 +                  android:id="@+id/uploader_choose_folder"
 +                  android:layout_width="fill_parent"
 +                  android:layout_height="wrap_content"
 +                  android:layout_gravity="bottom"
 +                  android:layout_weight="1"
 +                  android:text="@string/uploader_btn_upload_text" />
 +
        </LinearLayout>
  </RelativeLayout>
diff --combined res/values/strings.xml
@@@ -53,7 -53,6 +53,7 @@@
      <string name="sync_string_files">Files</string>
      <string name="setup_btn_connect">Connect</string>
      <string name="uploader_btn_upload_text">Upload</string>
 +    <string name="uploader_btn_new_folder_text">New folder</string>
      <string name="uploader_top_message">Choose upload folder:</string>
      <string name="uploader_wrn_no_account_title">No account found</string>
      <string name="uploader_wrn_no_account_text">There are no %1$s accounts on your device. Please setup an account first.</string>
        <string name="auth_fail_get_user_name">Your server is not returning a correct user id, please contact an administrator
        </string>
        <string name="auth_can_not_auth_against_server">Cannot authenticate against this server</string>
+     <string name="auth_account_does_not_exist">Account does not exist in the device yet</string>
      
      <string name="fd_keep_in_sync">Keep file up to date</string>
      <string name="common_rename">Rename</string>
        <string name="share_link_file_error">An error occurred while trying to share this file or folder</string>
        <string name="unshare_link_file_no_exist">Unable to unshare. Please check whether the file exists</string>
        <string name="unshare_link_file_error">An error occurred while trying to unshare this file or folder</string>
+     <string name="share_link_password_title">Enter a password</string>
+     <string name="share_link_empty_password">You must enter a password</string>
  
        <string name="activity_chooser_send_file_title">Send</string>
  
        <string name="prefs_instant_video_upload_path_title">Upload Video Path</string>
      <string name="download_folder_failed_content">Download of %1$s folder could not be completed</string>
  
-       <string name="shared_subject_header">shared</string>
-       <string name="with_you_subject_header">with you</string>
-       <string name="subject_token">%1$s %2$s &gt;&gt;%3$s&lt;&lt; %4$s</string>
+       <string name="subject_token">%1$s shared \"%2$s\" with you</string>
  
  </resources>
@@@ -1,6 -1,9 +1,9 @@@
- /* ownCloud Android client application
+ /**
+  *   ownCloud Android client application
+  *
+  *   @author Bartek Przybylski
   *   Copyright (C) 2012  Bartek Przybylski
-  *   Copyright (C) 2012-2013 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,
@@@ -26,6 -29,14 +29,6 @@@ import java.util.List
  import java.util.Stack;
  import java.util.Vector;
  
 -import com.owncloud.android.MainApp;
 -import com.owncloud.android.R;
 -import com.owncloud.android.authentication.AccountAuthenticator;
 -import com.owncloud.android.datamodel.FileDataStorageManager;
 -import com.owncloud.android.datamodel.OCFile;
 -import com.owncloud.android.files.services.FileUploader;
 -import com.owncloud.android.lib.common.utils.Log_OC;
 -
  import android.accounts.Account;
  import android.accounts.AccountManager;
  import android.app.AlertDialog;
@@@ -38,7 -49,6 +41,7 @@@ import android.content.DialogInterface.
  import android.content.DialogInterface.OnClickListener;
  import android.content.Intent;
  import android.content.SharedPreferences;
 +import android.content.res.Resources.NotFoundException;
  import android.database.Cursor;
  import android.net.Uri;
  import android.os.Bundle;
@@@ -52,34 -62,18 +55,31 @@@ import android.widget.AdapterView
  import android.widget.AdapterView.OnItemClickListener;
  import android.widget.Button;
  import android.widget.EditText;
 +import android.widget.ListView;
  import android.widget.SimpleAdapter;
  import android.widget.Toast;
  
  import com.actionbarsherlock.app.ActionBar;
 -import com.actionbarsherlock.app.SherlockListActivity;
  import com.actionbarsherlock.view.MenuItem;
 +import com.owncloud.android.MainApp;
 +import com.owncloud.android.R;
 +import com.owncloud.android.authentication.AccountAuthenticator;
 +import com.owncloud.android.datamodel.FileDataStorageManager;
 +import com.owncloud.android.datamodel.OCFile;
 +import com.owncloud.android.files.services.FileUploader;
 +import com.owncloud.android.lib.common.operations.RemoteOperation;
 +import com.owncloud.android.lib.common.operations.RemoteOperationResult;
 +import com.owncloud.android.lib.common.utils.Log_OC;
 +import com.owncloud.android.operations.CreateFolderOperation;
 +import com.owncloud.android.ui.dialog.CreateFolderDialogFragment;
  import com.owncloud.android.utils.DisplayUtils;
 +import com.owncloud.android.utils.ErrorMessageAdapter;
 +
  
  /**
   * This can be used to upload things to an ownCloud instance.
-  * 
-  * @author Bartek Przybylski
-  * 
   */
 -public class Uploader extends SherlockListActivity implements OnItemClickListener, android.view.View.OnClickListener {
 +public class Uploader extends FileActivity implements OnItemClickListener, android.view.View.OnClickListener {
      private static final String TAG = "ownCloudUploader";
  
      private Account mAccount;
@@@ -90,7 -84,7 +90,7 @@@
      private String mUploadPath;
      private FileDataStorageManager mStorageManager;
      private OCFile mFile;
 -
 +    
      private final static int DIALOG_NO_ACCOUNT = 0;
      private final static int DIALOG_WAITING = 1;
      private final static int DIALOG_NO_STREAM = 2;
              uploadFiles();
  
              break;
 +            
 +        case R.id.uploader_new_folder:
 +            CreateFolderDialogFragment dialog = CreateFolderDialogFragment.newInstance(mFile);
 +            dialog.show(getSupportFragmentManager(), "createdirdialog");
 +            break;
 +            
 +            
          default:
              throw new IllegalArgumentException("Wrong element clicked");
          }
  
      private void populateDirectoryList() {
          setContentView(R.layout.uploader_layout);
 +        
 +        ListView mListView = (ListView) findViewById(android.R.id.list);
  
          String current_dir = mParents.peek();
          if(current_dir.equals("")){
                                                  R.layout.uploader_list_item_layout,
                                                  new String[] {"dirname"},
                                                  new int[] {R.id.textView1});
 -            setListAdapter(sa);
 -            Button btn = (Button) findViewById(R.id.uploader_choose_folder);
 -            btn.setOnClickListener(this);
 -            getListView().setOnItemClickListener(this);
 +            
 +            mListView.setAdapter(sa);
 +            Button btnChooseFolder = (Button) findViewById(R.id.uploader_choose_folder);
 +            btnChooseFolder.setOnClickListener(this);
 +            
 +            Button btnNewFolder = (Button) findViewById(R.id.uploader_new_folder);
 +            btnNewFolder.setOnClickListener(this);
 +            
 +            mListView.setOnItemClickListener(this);
          }
      }
  
          }
      }
      
 +    @Override
 +    public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
 +        super.onRemoteOperationFinish(operation, result);
 +        
 +      
 +        if (operation instanceof CreateFolderOperation) {
 +            onCreateFolderOperationFinish((CreateFolderOperation)operation, result);
 +        }
 +        
 +    }
 +    
 +    /**
 +     * Updates the view associated to the activity after the finish of an operation trying create a new folder
 +     * 
 +     * @param operation     Creation operation performed.
 +     * @param result        Result of the creation.
 +     */
 +    private void onCreateFolderOperationFinish(CreateFolderOperation operation, RemoteOperationResult result) {
 +        if (result.isSuccess()) {
 +            dismissLoadingDialog();
 +            populateDirectoryList();
 +        } else {
 +            dismissLoadingDialog();
 +            try {
 +                Toast msg = Toast.makeText(this, 
 +                        ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()), 
 +                        Toast.LENGTH_LONG); 
 +                msg.show();
 +
 +            } catch (NotFoundException e) {
 +                Log_OC.e(TAG, "Error while trying to show fail message " , e);
 +            }
 +        }
 +    }
 +    
 +    
      /**
       *  Loads the target folder initialize shown to the user.
       *