import com.owncloud.android.operations.UnshareLinkOperation;
import com.owncloud.android.services.OperationsService;
import com.owncloud.android.services.OperationsService.OperationsServiceBinder;
-import com.owncloud.android.ui.dialog.CreateFolderDialogFragment;
import com.owncloud.android.ui.dialog.LoadingDialog;
import com.owncloud.android.ui.dialog.SharePasswordDialogFragment;
import com.owncloud.android.utils.ErrorMessageAdapter;
*/
@Override
protected void onRestart() {
+ Log_OC.v(TAG, "onRestart() start");
super.onRestart();
- boolean validAccount = (mAccount != null && AccountUtils.setCurrentOwnCloudAccount(getApplicationContext(), mAccount.name));
+ boolean validAccount =
+ (mAccount != null && AccountUtils.setCurrentOwnCloudAccount(getApplicationContext(), mAccount.name));
if (!validAccount) {
swapToDefaultAccount();
}
+ Log_OC.v(TAG, "onRestart() end");
}
@Override
protected void onStart() {
+ Log_OC.v(TAG, "onStart() start");
super.onStart();
if (mAccountWasSet) {
onAccountSet(mAccountWasRestored);
}
+ Log_OC.v(TAG, "onStart() end");
}
@Override
protected void onResume() {
+ Log_OC.v(TAG, "onResume() start");
super.onResume();
if (mOperationsServiceBinder != null) {
doOnResumeAndBound();
}
-
+ Log_OC.v(TAG, "onResume() end");
}
@Override
protected void onPause() {
-
+ Log_OC.v(TAG, "onPause() start");
+
if (mOperationsServiceBinder != null) {
mOperationsServiceBinder.removeOperationListener(this);
}
super.onPause();
+ Log_OC.v(TAG, "onPause() end");
}
*/
protected void setAccount(Account account, boolean savedAccount) {
Account oldAccount = mAccount;
- boolean validAccount = (account != null && AccountUtils.setCurrentOwnCloudAccount(getApplicationContext(), account.name));
+ boolean validAccount =
+ (account != null && AccountUtils.setCurrentOwnCloudAccount(getApplicationContext(), account.name));
if (validAccount) {
mAccount = account;
mAccountWasSet = true;
}
}
- private void onSynchronizeFolderOperationFinish(SynchronizeFolderOperation operation, RemoteOperationResult result) {
+ private void onSynchronizeFolderOperationFinish(
+ SynchronizeFolderOperation operation, RemoteOperationResult result
+ ) {
if (!result.isSuccess() && result.getCode() != ResultCode.CANCELLED){
Toast t = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
Toast.LENGTH_LONG);
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
-import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import com.owncloud.android.ui.dialog.CreateFolderDialogFragment;
import com.owncloud.android.ui.dialog.SslUntrustedCertDialog;
import com.owncloud.android.ui.dialog.SslUntrustedCertDialog.OnSslUntrustedCertListener;
+import com.owncloud.android.ui.dialog.UploadSourceDialogFragment;
import com.owncloud.android.ui.fragment.FileDetailFragment;
import com.owncloud.android.ui.fragment.FileFragment;
import com.owncloud.android.ui.fragment.OCFileListFragment;
public static final String ACTION_DETAILS = "com.owncloud.android.ui.activity.action.DETAILS";
- private static final int ACTION_SELECT_CONTENT_FROM_APPS = 1;
- private static final int ACTION_SELECT_MULTIPLE_FILES = 2;
+ public static final int ACTION_SELECT_CONTENT_FROM_APPS = 1;
+ public static final int ACTION_SELECT_MULTIPLE_FILES = 2;
public static final int ACTION_MOVE_FILES = 3;
private static final String TAG = FileDisplayActivity.class.getSimpleName();
@Override
protected void onStart() {
+ Log_OC.d(TAG, "onStart() start");
super.onStart();
getSupportActionBar().setIcon(DisplayUtils.getSeasonalIconId());
+ Log_OC.d(TAG, "onStart() end");
}
@Override
boolean retval = true;
switch (item.getItemId()) {
case R.id.action_create_dir: {
- CreateFolderDialogFragment dialog =
- CreateFolderDialogFragment.newInstance(getCurrentDir());
- dialog.show(getSupportFragmentManager(), "createdirdialog");
+ CreateFolderDialogFragment dialog = CreateFolderDialogFragment.newInstance(getCurrentDir());
+ dialog.show(getSupportFragmentManager(), "createDirDialog");
break;
}
case R.id.action_sync_account: {
break;
}
case R.id.action_upload: {
- showDialog(DIALOG_CHOOSE_UPLOAD_SOURCE);
+ //showDialog(DIALOG_CHOOSE_UPLOAD_SOURCE);
+ UploadSourceDialogFragment dialog = UploadSourceDialogFragment.newInstance(getAccount());
+ dialog.show(getSupportFragmentManager(), "uploadSourceDialog");
+
break;
}
case R.id.action_settings: {
*
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
+ @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
+ Log_OC.e(TAG, "ON ACTIVITIRESULT IN FILE_DISPLAY_ACTIVITY");
if (requestCode == ACTION_SELECT_CONTENT_FROM_APPS && (resultCode == RESULT_OK || resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) {
//getClipData is only supported on api level 16+, Jelly Bean
},
DELAY_TO_REQUEST_OPERATION_ON_ACTIVITY_RESULTS
);
+
+ } else {
+ super.onActivityResult(requestCode, resultCode, data);
}
+
}
private void requestMultipleUpload(Intent data, int resultCode) {
if (cursor != null && cursor.moveToFirst()) {
String displayName = cursor.getString(
cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
- Log.i(TAG, "Display Name: " + displayName + "; mimeType: " + mimeType);
+ Log_OC.i(TAG, "Display Name: " + displayName + "; mimeType: " + mimeType);
displayName.replace(File.separatorChar, '_');
displayName.replace(File.pathSeparatorChar, '_');
@Override
protected void onResume() {
- super.onResume();
Log_OC.d(TAG, "onResume() start");
-
+ super.onResume();
+
// refresh list of files
refreshListOfFilesFragment();
}
- Log_OC.d(TAG, "onPause() end");
super.onPause();
+ Log_OC.d(TAG, "onPause() end");
}
dialog = working_dialog;
break;
}
+ /*
case DIALOG_CHOOSE_UPLOAD_SOURCE: {
// }
} else if (item == 1) {
Intent action = new Intent(Intent.ACTION_GET_CONTENT);
- action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE);
+ 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);
});
dialog = builder.create();
break;
- }
+ } */
case DIALOG_CERT_NOT_SAVED: {
builder = new AlertDialog.Builder(this);
builder.setMessage(getResources().getString(R.string.ssl_validator_not_saved));
}
/**
- * Translates a content URI of an content to a physical path on the disk
- *
- * @param uri The URI to resolve
- * @return The path to the content or null if it could not be found
- */
- public String getPath(Uri uri) {
- final boolean isKitKatOrLater = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
-
- // DocumentProvider
- if (isKitKatOrLater && DocumentsContract.isDocumentUri(getApplicationContext(), uri)) {
- // ExternalStorageProvider
- if (UriUtils.isExternalStorageDocument(uri)) {
- final String docId = DocumentsContract.getDocumentId(uri);
- final String[] split = docId.split(":");
- final String type = split[0];
-
- if ("primary".equalsIgnoreCase(type)) {
- return Environment.getExternalStorageDirectory() + "/" + split[1];
- }
- }
- // DownloadsProvider
- else if (UriUtils.isDownloadsDocument(uri)) {
-
- final String id = DocumentsContract.getDocumentId(uri);
- final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"),
- Long.valueOf(id));
-
- return UriUtils.getDataColumn(getApplicationContext(), contentUri, null, null);
- }
- // MediaProvider
- else if (UriUtils.isMediaDocument(uri)) {
- final String docId = DocumentsContract.getDocumentId(uri);
- final String[] split = docId.split(":");
- final String type = split[0];
-
- Uri contentUri = null;
- if ("image".equals(type)) {
- contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
- } else if ("video".equals(type)) {
- contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
- } else if ("audio".equals(type)) {
- contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
- }
-
- final String selection = "_id=?";
- final String[] selectionArgs = new String[] { split[1] };
-
- return UriUtils.getDataColumn(getApplicationContext(), contentUri, selection, selectionArgs);
- }
- // Documents providers returned as content://...
- else if (UriUtils.isContentDocument(uri)) {
- return uri.toString();
- }
- }
- // MediaStore (and general)
- else if ("content".equalsIgnoreCase(uri.getScheme())) {
-
- // Return the remote address
- if (UriUtils.isGooglePhotosUri(uri))
- return uri.getLastPathSegment();
-
- return UriUtils.getDataColumn(getApplicationContext(), uri, null, null);
- }
- // File
- else if ("file".equalsIgnoreCase(uri.getScheme())) {
- return uri.getPath();
- }
- return null;
- }
-
- /**
* Pushes a directory to the drop down list
* @param directory to push
* @throws IllegalArgumentException If the {@link OCFile#isFolder()} returns false.
private void sortByName(boolean ascending){
getListOfFilesFragment().sortByName(ascending);
}
+
+
+
+ /**
+ * Translates a content URI of a content to a physical path on the disk
+ *
+ * @param uri The URI to resolve
+ * @return The path to the content or null if it could not be found
+ */
+ @TargetApi(Build.VERSION_CODES.KITKAT)
+ public String getPath(Uri uri) {
+ final boolean isKitKatOrLater = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
+
+ // DocumentProvider
+ if (isKitKatOrLater && DocumentsContract.isDocumentUri(this, uri)) {
+ // ExternalStorageProvider
+ if (UriUtils.isExternalStorageDocument(uri)) {
+ final String docId = DocumentsContract.getDocumentId(uri);
+ final String[] split = docId.split(":");
+ final String type = split[0];
+
+ if ("primary".equalsIgnoreCase(type)) {
+ return Environment.getExternalStorageDirectory() + "/" + split[1];
+ }
+ }
+ // DownloadsProvider
+ else if (UriUtils.isDownloadsDocument(uri)) {
+
+ final String id = DocumentsContract.getDocumentId(uri);
+ final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"),
+ Long.valueOf(id));
+
+ return UriUtils.getDataColumn(this, contentUri, null, null);
+ }
+ // MediaProvider
+ else if (UriUtils.isMediaDocument(uri)) {
+ final String docId = DocumentsContract.getDocumentId(uri);
+ final String[] split = docId.split(":");
+ final String type = split[0];
+
+ Uri contentUri = null;
+ if ("image".equals(type)) {
+ contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
+ } else if ("video".equals(type)) {
+ contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
+ } else if ("audio".equals(type)) {
+ contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
+ }
+
+ final String selection = "_id=?";
+ final String[] selectionArgs = new String[] { split[1] };
+
+ return UriUtils.getDataColumn(this, contentUri, selection, selectionArgs);
+ }
+ // Documents providers returned as content://...
+ else if (UriUtils.isContentDocument(uri)) {
+ return uri.toString();
+ }
+ }
+ // MediaStore (and general)
+ else if ("content".equalsIgnoreCase(uri.getScheme())) {
+
+ // Return the remote address
+ if (UriUtils.isGooglePhotosUri(uri))
+ return uri.getLastPathSegment();
+
+ return UriUtils.getDataColumn(this, uri, null, null);
+ }
+ // File
+ else if ("file".equalsIgnoreCase(uri.getScheme())) {
+ return uri.getPath();
+ }
+ return null;
+ }
+
+
+
}
private Account mAccountOnCreation;
private DialogFragment mCurrentDialog;
- public static final String EXTRA_CHOSEN_FILES = UploadFilesActivity.class.getCanonicalName() + ".EXTRA_CHOSEN_FILES";
+ public static final String EXTRA_CHOSEN_FILES =
+ UploadFilesActivity.class.getCanonicalName() + ".EXTRA_CHOSEN_FILES";
public static final int RESULT_OK_AND_MOVE = RESULT_FIRST_USER;
- private static final String KEY_DIRECTORY_PATH = UploadFilesActivity.class.getCanonicalName() + ".KEY_DIRECTORY_PATH";
+ private static final String KEY_DIRECTORY_PATH =
+ UploadFilesActivity.class.getCanonicalName() + ".KEY_DIRECTORY_PATH";
private static final String TAG = "UploadFilesActivity";
private static final String WAIT_DIALOG_TAG = "WAIT";
private static final String QUERY_TO_MOVE_DIALOG_TAG = "QUERY_TO_MOVE";
@Override
protected void onSaveInstanceState(Bundle outState) {
- // responsibility of restore is preferred in onCreate() before than in onRestoreInstanceState when there are Fragments involved
+ // responsibility of restore is preferred in onCreate() before than in
+ // onRestoreInstanceState when there are Fragments involved
Log_OC.d(TAG, "onSaveInstanceState() start");
super.onSaveInstanceState(outState);
outState.putString(UploadFilesActivity.KEY_DIRECTORY_PATH, mCurrentDir.getAbsolutePath());
File localFile = new File(localPath);
total += localFile.length();
}
- return (FileStorageUtils.getUsableSpace(mAccountOnCreation.name) >= total);
+ return (new Boolean(FileStorageUtils.getUsableSpace(mAccountOnCreation.name) >= total));
}
/**
finish();
} else {
- // show a dialog to query the user if wants to move the selected files to the ownCloud folder instead of copying
+ // show a dialog to query the user if wants to move the selected files
+ // to the ownCloud folder instead of copying
String[] args = {getString(R.string.app_name)};
- ConfirmationDialogFragment dialog = ConfirmationDialogFragment.newInstance(R.string.upload_query_move_foreign_files, args, R.string.common_yes, -1, R.string.common_no);
+ ConfirmationDialogFragment dialog = ConfirmationDialogFragment.newInstance(
+ R.string.upload_query_move_foreign_files, args, R.string.common_yes, -1, R.string.common_no
+ );
dialog.setOnConfirmationListener(UploadFilesActivity.this);
dialog.show(getSupportFragmentManager(), QUERY_TO_MOVE_DIALOG_TAG);
}
public void onConfirmation(String callerTag) {
Log_OC.d(TAG, "Positive button in dialog was clicked; dialog tag is " + callerTag);
if (callerTag.equals(QUERY_TO_MOVE_DIALOG_TAG)) {
- // return the list of selected files to the caller activity (success), signaling that they should be moved to the ownCloud folder, instead of copied
+ // return the list of selected files to the caller activity (success),
+ // signaling that they should be moved to the ownCloud folder, instead of copied
Intent data = new Intent();
data.putExtra(EXTRA_CHOSEN_FILES, mFileListFragment.getCheckedFilePaths());
setResult(RESULT_OK_AND_MOVE, data);
--- /dev/null
+/**
+ * ownCloud Android client application
+ *
+ * @author David A. Velasco
+ * 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,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package com.owncloud.android.ui.dialog;
+
+import android.accounts.Account;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Build;
+import android.os.Bundle;
+
+import com.actionbarsherlock.app.SherlockDialogFragment;
+import com.owncloud.android.R;
+import com.owncloud.android.lib.common.utils.Log_OC;
+import com.owncloud.android.ui.activity.FileActivity;
+import com.owncloud.android.ui.activity.UploadFilesActivity;
+
+
+/**
+ * Dialog showing two options to allow the user upload files from the filesystem or from other apps.
+ *
+ * Assumes that its parent activity extends {@link FileActivity}
+ */
+public class UploadSourceDialogFragment extends SherlockDialogFragment {
+
+ private final static String TAG = UploadSourceDialogFragment.class.getSimpleName();
+ private final static String ARG_ACCOUNT = UploadSourceDialogFragment.class.getSimpleName() + ".ARG_ACCOUNT";
+
+ public static final int ACTION_SELECT_CONTENT_FROM_APPS = 1;
+ public static final int ACTION_SELECT_MULTIPLE_FILES = 2;
+
+ public static UploadSourceDialogFragment newInstance(Account account) {
+ UploadSourceDialogFragment f = new UploadSourceDialogFragment();
+ Bundle args = new Bundle();
+ args.putParcelable(ARG_ACCOUNT, account);
+ f.setArguments(args);
+ return f;
+ }
+
+ public UploadSourceDialogFragment() {
+ super();
+ Log_OC.v(TAG, "constructor");
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+
+ String[] allTheItems = {
+ getString(R.string.actionbar_upload_files),
+ getString(R.string.actionbar_upload_from_apps)
+ };
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(getSherlockActivity());
+ builder.setTitle(R.string.actionbar_upload);
+ builder.setItems(allTheItems, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int item) {
+ if (item == 0) {
+ Intent action = new Intent(getSherlockActivity(), UploadFilesActivity.class);
+ action.putExtra(
+ UploadFilesActivity.EXTRA_ACCOUNT,
+ ((FileActivity)getSherlockActivity()).getAccount()
+ );
+ //startActivityForResult(action, ACTION_SELECT_MULTIPLE_FILES); // this flow seems broken;
+ // Actionbarsherlock, maybe?
+ getSherlockActivity().startActivityForResult(action, ACTION_SELECT_MULTIPLE_FILES);
+
+ } else if (item == 1) {
+ 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( // this flow seems broken;
+ // Actionbarsherlock, maybe?
+ getSherlockActivity().startActivityForResult(
+ Intent.createChooser(action, getString(R.string.upload_chooser_title)),
+ ACTION_SELECT_CONTENT_FROM_APPS
+ );
+ }
+ }
+ });
+ return builder.create();
+ }
+
+}