Merge commit 'refs/pr/701' into create_folder_during_upload_pr_701_with_develop

This commit is contained in:
masensio 2015-01-30 12:10:15 +01:00
commit 7f6c5bd3b2
3 changed files with 96 additions and 20 deletions

View file

@ -31,10 +31,29 @@
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>

View file

@ -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>

View file

@ -26,14 +26,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;
@ -46,6 +38,7 @@ import android.content.DialogInterface.OnCancelListener;
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;
@ -59,13 +52,26 @@ 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.
@ -73,7 +79,7 @@ import com.owncloud.android.utils.DisplayUtils;
* @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;
@ -268,6 +274,13 @@ public class Uploader extends SherlockListActivity implements OnItemClickListene
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");
}
@ -298,6 +311,8 @@ public class Uploader extends SherlockListActivity implements OnItemClickListene
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("")){
getSupportActionBar().setTitle(getString(R.string.default_display_name_for_root_folder));
@ -330,10 +345,15 @@ public class Uploader extends SherlockListActivity implements OnItemClickListene
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);
}
}
@ -452,6 +472,42 @@ public class Uploader extends SherlockListActivity implements OnItemClickListene
}
}
@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.
*