Skip to content

Commit

Permalink
cleanup for code review duplicate code for upload activity calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyScherzinger committed Mar 3, 2016
1 parent e4d936e commit 7e82baa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 33 deletions.
22 changes: 0 additions & 22 deletions src/com/owncloud/android/ui/activity/FileDisplayActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -619,28 +619,6 @@ public void createFolder() {
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) {
Expand Down
14 changes: 14 additions & 0 deletions src/com/owncloud/android/ui/activity/UploadFilesActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -153,6 +154,19 @@ public void onCreate(Bundle savedInstanceState) {
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) {
Expand Down
13 changes: 2 additions & 11 deletions src/com/owncloud/android/ui/fragment/OCFileListFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,17 +226,8 @@ private void registerFabUploadListeners() {
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();
}
Expand Down

0 comments on commit 7e82baa

Please sign in to comment.