import android.os.Bundle;
import android.os.Environment;
import android.support.v4.app.DialogFragment;
-import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.ActionBar.OnNavigationListener;
-import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.MenuItem;
+import com.owncloud.android.R;
import com.owncloud.android.ui.dialog.IndeterminateProgressDialog;
import com.owncloud.android.ui.fragment.ConfirmationDialogFragment;
import com.owncloud.android.ui.fragment.LocalFileListFragment;
import com.owncloud.android.ui.fragment.ConfirmationDialogFragment.ConfirmationDialogFragmentListener;
+import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.FileStorageUtils;
+import com.owncloud.android.utils.Log_OC;
-import com.owncloud.android.Log_OC;
-import com.owncloud.android.R;
/**
* Displays local files and let the user choose what of them wants to upload
*
*/
-public class UploadFilesActivity extends SherlockFragmentActivity implements
+public class UploadFilesActivity extends FileActivity implements
LocalFileListFragment.ContainerActivity, OnNavigationListener, OnClickListener, ConfirmationDialogFragmentListener {
private ArrayAdapter<String> mDirectories;
private LocalFileListFragment mFileListFragment;
private Button mCancelBtn;
private Button mUploadBtn;
- private Account mAccount;
+ private Account mAccountOnCreation;
private DialogFragment mCurrentDialog;
- public static final String EXTRA_ACCOUNT = UploadFilesActivity.class.getCanonicalName() + ".EXTRA_ACCOUNT";
public static final String EXTRA_CHOSEN_FILES = UploadFilesActivity.class.getCanonicalName() + ".EXTRA_CHOSEN_FILES";
public static final int RESULT_OK_AND_MOVE = RESULT_FIRST_USER;
mCurrentDir = Environment.getExternalStorageDirectory();
}
- mAccount = getIntent().getParcelableExtra(EXTRA_ACCOUNT);
+ mAccountOnCreation = getAccount();
/// USER INTERFACE
mCancelBtn.setOnClickListener(this);
mUploadBtn = (Button) findViewById(R.id.upload_files_btn_upload);
mUploadBtn.setOnClickListener(this);
+
// Action bar setup
ActionBar actionBar = getSupportActionBar();
+ actionBar.setIcon(DisplayUtils.getSeasonalIconId());
actionBar.setHomeButtonEnabled(true); // mandatory since Android ICS, according to the official documentation
actionBar.setDisplayHomeAsUpEnabled(mCurrentDir != null && mCurrentDir.getName() != null);
actionBar.setDisplayShowTitleEnabled(false);
File localFile = new File(localPath);
total += localFile.length();
}
- return (FileStorageUtils.getUsableSpace(mAccount.name) >= total);
+ return (FileStorageUtils.getUsableSpace(mAccountOnCreation.name) >= total);
}
/**
public void onCancel(String callerTag) {
/// nothing to do; don't finish, let the user change the selection
Log_OC.d(TAG, "Negative button in dialog was clicked; dialog tag is " + callerTag);
+ }
+
+
+ @Override
+ protected void onAccountSet(boolean stateWasRecovered) {
+ if (getAccount() != null) {
+ if (!mAccountOnCreation.equals(getAccount())) {
+ setResult(RESULT_CANCELED);
+ finish();
+ }
+
+ } else {
+ Log_OC.wtf(TAG, "onAccountChanged was called with NULL account associated!");
+ setResult(RESULT_CANCELED);
+ finish();
+ }
}