mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 21:55:48 +03:00
cleanup for code review duplicate code for upload activity calls.
This commit is contained in:
parent
e4d936e837
commit
7e82baa8bc
3 changed files with 16 additions and 33 deletions
|
@ -619,28 +619,6 @@ public class FileDisplayActivity extends HookActivity
|
|||
dialog.show(getSupportFragmentManager(), DIALOG_CREATE_FOLDER);
|
||||
}
|
||||
|
||||
public void uploadLocalFilesSelected() {
|
||||
Intent action = new Intent(this, UploadFilesActivity.class);
|
||||
action.putExtra(
|
||||
UploadFilesActivity.EXTRA_ACCOUNT,
|
||||
getAccount()
|
||||
);
|
||||
startActivityForResult(action, ACTION_SELECT_MULTIPLE_FILES);
|
||||
}
|
||||
|
||||
public void uploadFromOtherAppsSelected() {
|
||||
Intent action = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE);
|
||||
//Intent.EXTRA_ALLOW_MULTIPLE is only supported on api level 18+, Jelly Bean
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
action.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
|
||||
}
|
||||
startActivityForResult(
|
||||
Intent.createChooser(action, getString(R.string.upload_chooser_title)),
|
||||
ACTION_SELECT_CONTENT_FROM_APPS
|
||||
);
|
||||
}
|
||||
|
||||
private void startSynchronization() {
|
||||
Log_OC.d(TAG, "Got to start sync");
|
||||
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.KITKAT) {
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
package com.owncloud.android.ui.activity;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
|
@ -153,6 +154,19 @@ public class UploadFilesActivity extends FileActivity implements
|
|||
Log_OC.d(TAG, "onCreate() end");
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to launch the UploadFilesActivity for which you would like a result when it finished.
|
||||
* Your onActivityResult() method will be called with the given requestCode.
|
||||
*
|
||||
* @param activity the activity which should call the upload activity for a result
|
||||
* @param account the account for which the upload activity is called
|
||||
* @param requestCode If >= 0, this code will be returned in onActivityResult()
|
||||
*/
|
||||
public static void startUploadActivityForResult(Activity activity, Account account, int requestCode) {
|
||||
Intent action = new Intent(activity, UploadFilesActivity.class);
|
||||
action.putExtra(EXTRA_ACCOUNT, (account));
|
||||
activity.startActivityForResult(action, requestCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
|
|
@ -226,17 +226,8 @@ public class OCFileListFragment extends ExtendedListFragment
|
|||
getFabUpload().setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent action = new Intent(getActivity(), UploadFilesActivity.class);
|
||||
action.putExtra(
|
||||
UploadFilesActivity.EXTRA_ACCOUNT,
|
||||
((FileActivity)getActivity()).getAccount()
|
||||
);
|
||||
//startActivityForResult(action, ACTION_SELECT_MULTIPLE_FILES);
|
||||
// this flow seems broken;
|
||||
getActivity().startActivityForResult(
|
||||
action,
|
||||
FileDisplayActivity.ACTION_SELECT_MULTIPLE_FILES
|
||||
);
|
||||
UploadFilesActivity.startUploadActivityForResult(getActivity(), ((FileActivity)getActivity())
|
||||
.getAccount(), FileDisplayActivity.ACTION_SELECT_MULTIPLE_FILES);
|
||||
getFabMain().collapse();
|
||||
recordMiniFabClick();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue